Hi Guys,
I want to delete the contents of a directory and i don't really know how to go about doing that. The directory may or may not contain files and it will contain an unknown number of files.
Any help would be greatly appreciated.
Printable View
Hi Guys,
I want to delete the contents of a directory and i don't really know how to go about doing that. The directory may or may not contain files and it will contain an unknown number of files.
Any help would be greatly appreciated.
VB Code:
On Error Resume Next Kill "C:\SomeDir\*.*"
:)
The FileSystemObject would be the easiest way although it will require a reference to the scrrun.dll.
VB Code:
Private Sub KillFiles() Dim fso as FileSystemObject Dim myFolder as Folder Dim myFile as File Set fso = new FileSystemObject Set myFolder = fso.GetFolder(<FolderPath Here>) For Each myFile in myFolder.Files myFile.Delete(True) Next myFile End Sub
try that out..
Thanks crptcblade. Too simple a solution to have occured to me.
If you want another piece of code:;)VB Code:
Shell "Kill C:\SomeDir\*.*"
Sastraxi, Isn't that pretty much the same code crptcblade posted?
Yeh, but meh. :) Just stating that you can still use the commandline, even though it's Windows ;)