As per MSDN PathFileExists()
function only supports filepath < 260
I want to check if a path exists on a remote location. Now legally I can create a file
Since all Shell Path Handling Functions are limited to MAX_PATH
- 1 characters you will have to use kernel32 functions instead if you need to support longer file names. Your options are:
While FindFirstFile is fairly straight forward you are required to call FindClose if the function does not return an error code. This triggers an additional network round-trip if you are querying for a file on a network. The additional network round-trip is also triggered for CreateFile where you have to cleanup the HANDLE
calling CloseHandle. Plus it may give the wrong answer.
The remaining option to use GetFileAttributes is the suggested way to query for file existence if you need to support file names longer than MAX_PATH
characters.