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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete directory contents

Status
Not open for further replies.

wASP

Programmer
Jun 28, 2001
23
0
0
ZA
HI

how can i programatically delete all files within a specified directory using vb6?

Regards
w@sp

>:):O> wASP >:):O>
 
You can use the kill command to acheive this.

Like so.

Code:
Dim MyDirectory As String

MyDirectory = "c:\test" ' Name of directory want to delete all files in.
Kill MyDirectory & "\*.*"   ' Delete all files in 'MyDirectory'
 
any way i could modify this code to check if ANY files exist before killing all files, as a file not found error occurs if directory is already empty ?

>:):O> wASP >:):O>
 
Use the DIR function first.



________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Sorry, hit Submit instead of Preview:
[tt]
If Len(Dir("c:\test\fred\*.*")) = 0 Then
'Directory is empty
Else
'do delete here[/tt]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top