Question
In a Windows C application, I want to check the parameter passed to the function to make sure that the specified path exists. *
How do you check if a directory exists in Windows in C?
* I understand that you can get into the conditions of the race when you check the existence and time, when you use the path that it no longer exists, but I can deal with it.
Additional background
Knowing explicitly that a directory exists or does not exist can be difficult when access permissions are allowed. It is possible that when you try to determine if a directory exists, the process does not have access rights to the directory or parent directory. This is normal for my needs. If the directory does not exist OR I cannot access it, then both applications are considered as an invalid path failure in my application, so I do not need to distinguish. (Virtual) if your solution provides for this difference.
Any solution in C, C runtime library or Win32 API is fine, but ideally I would like to stick to commonly loaded libraries (like kernel32, user32, etc.) and avoid solutions that are standard libraries (like PathFileExists in Shlwapi .dll). Again, (virtual) bonus points if your solution is cross-platform.
Similar
How to check if a file exists or not using Win32?
c windows winapi
Zach Burlingame Jun 02 '11 at 17:57 2011-06-02 17:57
source share