How do I do this?
I know that I could loop through each and every folder deleting each file using the Kill method, but this would be a pain. Is there any way to do this better?
Flustor
Printable View
How do I do this?
I know that I could loop through each and every folder deleting each file using the Kill method, but this would be a pain. Is there any way to do this better?
Flustor
You could always use Deltree, which I believe deletes every file in every folder (subdirectories).
VB Code:
Shell "command.com Deltree /Y C:\MyFolder\Stuff\MoreStuff\*.*
You can use the File System Object and I think that it will delete the folder along with the files.
Excellent!! I'll give that a try.
thanx!
I've just found that Microsoft (in their infinate wisdem) have dumped Deltree. One of my favorates in the days of Dos 6.
So that shell command doesn't work! Good idea though (which I'll be using in future).. any others?
VB Code:
Dim fso As New FileSystemObject If fso.FolderExists Then fso.DeleteFolder ("C:\Temp")
You need the Microsoft Scripting Runtime in your references.
You could technically do a recursive kill feature and kill *.* in every sub directory then kill each subdirectory then the directory you wanted to kill, but this is much more convenient.