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 all FIles and folders.

Status
Not open for further replies.

DerickD

IS-IT--Management
Sep 19, 2002
93
LU
Hi All,

Thanks for taking the time.

I have a Database that imports all the folder names from a specified place and puts them all into a single column table.

I would then like to go through each of these folders and delete the folder and all contents. So the original folders contain many more folders..etc.. I want to delete them all!

Is there a simple command that I can just delete all folder names and contents.


(
I have all the other code so just an example like :
DeleteAllFiles ("Z:\Reports\*.*")
)


Thanks alot,
Derick.
 
Hi,

I'm not sure if you can delete the sub folders and files all in one hit.

You can delete all files in a folder by using Kill

eg.

Kill "C:\Test\*.*"

and remove directories using

Rmdir "C:\Test\"

Both are explained in the Help.

Hope this helps...



There are two ways to write error-free programs; only the third one works.
 
This example uses the FileSystemObject Object:

On Error GoTo Err_DeleteFolder
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder ("C:\TestFolder")
Exit Sub
Err_DeleteFolder:
MsgBox Err.Number & " - " & Err.Description

Use this procedure carefully as it will delete the folder "C:\TestFolder", all files and sub folders in "C:\TestFolder" without putting them in the Recycle Bin.

See help for further info on the FileSystemObject Object.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top