Checking for existence of file before issuing Kill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using Kill to delete a file; however, I need to bypass the "file does
not exist" messages that is returned if the file does not exists. How can I
check to see if a file exists so that I can just run the Kill if the file
exists?
 
Dir("MyPathFileName") will return the file name if it exists or "" if it
doesn't.

However, what if the file exists but is in use, locked or otherwise
unkillable? You will still get an error message. You may be better off
simply doing inline error checking for a few lines with On Error Resume Next
and not checking for its existence, just whether the Kill raised an error,
then turn your normal error handling back on.
 

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

Back
Top