
Finding if File and Path Exists?
Quote:
>I'm looking for a file based on what a user types in. I'm trying to use
>the dir() command to see if the file exists. My problem is that the user
>could type in an invalid path. If this happens, I get a path not found
>error. How can I check to see if the file and path both exist?
You could go ahead and use dir() and just trap errors, and ask for
re-input when an error occurs.
You can test for the file \sub\dir\path\. (note period at end) to
determine if subdirectory \sub\dir\path exists. If it does, you'll get
the name of the first real file in it. If it doesn't, you'll get a path
not found error that you can trap. If it exists but it's empty, you'll
get a null string.
Steve Young
Young Computing