Click to See Complete Forum and Search --> : Deleting whole durectories...


Waseem Sadiq
February 28th, 2000, 08:21 AM
Hi,

my app creates a directory and puts some subdirectories in it with some files. When the app exits I want to delete all the directories.
I looked at the kill and rmdir command, but kill can only be used on files and rmdir doesn't do subdirectories.
Anybody got any ideas?
Thanks

Lothar Haensler
February 28th, 2000, 08:51 AM
use the FileSystemobject

Dim fso
set fso = CreateObject("Scripting.FileSystemObject")
Dim filespec as string
filespec = "c:\schrott\test"
fso.DeleteFolder filespec, true

Lothar Haensler
February 28th, 2000, 08:53 AM
small improvement:

Dim fso as Scripting.FileSystemObject
set fso = new Scripting.FileSystemObject
Dim filespec as string
filespec = "c:\schrott\test"
fso.DeleteFolder filespec, true



use early binding: add a reference to "microsoft scripting runtime" to your vb project.
and yes, it does delete subfolders.