Quote Originally Posted by pepegriyo2016 View Post
This is not good, it generates an error, even if it is controlled with On Error Summary, which is not good in programming.
While it is indeed good practice to avoid excessive use of On Error Resume Next, there's really nothing wrong with it when employed in situations like in that ANSI-only FileExists function. There's really no way of preventing the GetAttr function from raising an error when supplied with an invalid path, is there?

That said, it seems you've overlooked the other Unicode-aware FileExists routine there, which is what I actually wanted to refer you to, but obviously did a poor job of pointing it out.

Quote Originally Posted by pepegriyo2016 View Post
Krool, please could you change the function by the API of Windows?
PathFileExists isn't really the best choice because it doesn't distinguish files from folders:

Quote Originally Posted by MSDN
Determines whether a path to a file system object such as a file or folder is valid.
Quote Originally Posted by Kenny Kerr
The shell provides the PathFileExists function which is simpler than the approaches mentioned thus far but is limited in that it does not distinguish between files and directories.
Also, as it turns out, PathFileExists relies on GetFileAttributes anyway, so why not call GetFileAttributes directly ourselves? (and in the process, avoid loading shlwapi.dll if that's the only thing we need it for)

Quote Originally Posted by Kenny Kerr
Incidentally, the PathFileExists function I mentioned above uses GetFileAttributes internally if it determines that you’re running on a supported version of Windows.
See these articles if you are still unconvinced GetFileAttributes is the way to go: