Hello
I know this is easy, but couldn't find the answer in vb help.
I have 2 questions:
1- How can I create a folder such as "[SystemFolder]\Example\" ?
2- How can I delete a folder/file such as "[My Documents]\example.txt"?
Thank you
Printable View
Hello
I know this is easy, but couldn't find the answer in vb help.
I have 2 questions:
1- How can I create a folder such as "[SystemFolder]\Example\" ?
2- How can I delete a folder/file such as "[My Documents]\example.txt"?
Thank you
You cannot modify any of the system's folders/files. What exactly are you trying to accomplish?
The exact thing I need for now, is deleting and creating files and folders. For example:Quote:
You cannot modify any of the system's folders/files. What exactly are you trying to accomplish?
I want to create "C:\New Folder\"
and I want to delete "C:\New Folder\myfile.txt"
Thank you
To create/delete a folder, you can use the Directory class. To delete a file, you can use the file class
vb Code:
If Not IO.Directory.Exists("C:\SomeFolderName\SubFolderName") Then IO.Directory.CreateDirectory("C:\SomeFolderName\SubFolderName") End If If IO.File.Exists("C:\test.txt") Then IO.File.Delete("C:\test.txt") End If
you can use this code its to sample
My.Computer.FileSystem.CreateDirectory("C:\NewDirectory").....to create
My.Computer.FileSystem.DeleteFile("C:\Test.txt", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin).........to Delete
Good luck
Thank you Stanav and TheBeginner. You solved my problem.