* Wildcard and FileExists

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top