File exist

  • Thread starter Thread starter mirna
  • Start date Start date
M

mirna

Hi,

How can I verify if a folder or a file exists on my PC by
code before continuing a process

Thankss
 
Hi Allen

Thanks for your response, I tried Dir, but it's not seem
working, This is what I have:

dim sRepNam as String
sRepNam = "C:\Applications"

If Dir(sRepName) <> "" then
fs.deleteFolder sRepNam
else
MsgBox "This folder doesn't exist"
End if

Thanks
 
mirna said:
Hi Allen

Thanks for your response, I tried Dir, but it's not seem
working, This is what I have:

dim sRepNam as String
sRepNam = "C:\Applications"

If Dir(sRepName) <> "" then
fs.deleteFolder sRepNam
else
MsgBox "This folder doesn't exist"
End if

Thanks

For a folder, you need to specify the vbDirectory attribute:

If Len(Dir(sRepName, vbDirectory) > 0 Then

I notice, though, that you appear to be using a FileSystemObject to
delete the folder. If you're going to use a FileSystemObject, you could
just as easily use its FolderExists method.
 
Thank you Dirk you're right

-----Original Message-----


For a folder, you need to specify the vbDirectory attribute:

If Len(Dir(sRepName, vbDirectory) > 0 Then

I notice, though, that you appear to be using a FileSystemObject to
delete the folder. If you're going to use a FileSystemObject, you could
just as easily use its FolderExists method.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Back
Top