Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete contents

Status
Not open for further replies.

bosky

Programmer
Oct 30, 2003
15
IN
How do you delete the contents of a directory?
 
Do you want to delete the directory, or the files in the directory(and leave the directory)?

if you want to delete the directory,
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder("c:\MyDir\")


If you want to delete the files

Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
f1.delete
Next

Note: I haven't tested any of these.


______________________________
- David Lanouette
- Lanouette Consulting, LLC
- DLanouette@Computer.org
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top