P
Paul
I'm trying to make get my app to delete all the files in a specified folder
and all the files within the folders of the specified folder.
e.g.
Folder 1 contains three files (File1, File2, File3) and two folders
(Subfolder 1, Subfolder 2).
.......I need to delete File1, File2, File3.
Subfolder 1 contains FileA.
.......Need to delete FileA.
Subfolder 2 contains FileB, FileC, FileD.
.......Need to del FileB, FileC, FileD.
So, basically all files but keeping the folders, so I'll have an empty
folder structure. The code below doesn't seem to work for me. I have admin
rights so file/folder privileges not applicable here.
Dim ParentFolder As New System.IO.DirectoryInfo("C:\TEST\")
Dim Folder As System.IO.DirectoryInfo
Dim File As System.IO.FileInfo
For Each Folder In ParentFolder.GetDirectories()
For Each File In Folder.GetFiles
File.Delete()
Next File
Next Folder
Any ideas?
Cheers,
Paul
and all the files within the folders of the specified folder.
e.g.
Folder 1 contains three files (File1, File2, File3) and two folders
(Subfolder 1, Subfolder 2).
.......I need to delete File1, File2, File3.
Subfolder 1 contains FileA.
.......Need to delete FileA.
Subfolder 2 contains FileB, FileC, FileD.
.......Need to del FileB, FileC, FileD.
So, basically all files but keeping the folders, so I'll have an empty
folder structure. The code below doesn't seem to work for me. I have admin
rights so file/folder privileges not applicable here.
Dim ParentFolder As New System.IO.DirectoryInfo("C:\TEST\")
Dim Folder As System.IO.DirectoryInfo
Dim File As System.IO.FileInfo
For Each Folder In ParentFolder.GetDirectories()
For Each File In Folder.GetFiles
File.Delete()
Next File
Next Folder
Any ideas?
Cheers,
Paul