* Wildcard and FileExists

B

Bruce

Can anyone tell me why the * wildcard does not work in the example below?

Rgds

Bruce

myDest = "C:\test\"
If fs.FileExists(myDest & "*.mdb") Then
fs.DeleteFile myDest & "*.mdb", True
End If
 
K

Ken Snell [MVP]

ummm... because FileExists expects to be given the full name of a single
file.

What are you wanting to do? Delete all files in a folder?
 
K

Ken Snell [MVP]

Then I would use a slightly different approach:


Dim strFile As String
strFile = Dir(myDest & "*.mdb")
Do While strFile <> ""
Kill myDest & strFile
strFile = Dir()
Loop
 
Top