home ‣ Check if file exists on Windows
| 02 Jan 2006 · Tags: win32, c, programming | ← newer • 202 of 588 • older → |
Windows doesn't have a built-in function that checks if a file with a given name
exists. It can be trivially written using GetFileAttributes or FindFirstFile
APIs. Version below uses GetFileAttributes.
/* Return TRUE if file 'fileName' exists */
bool FileExists(const TCHAR *fileName)
{
DWORD fileAttr;
fileAttr = GetFileAttributes(fileName);
if (0xFFFFFFFF == fileAttr)
return false;
return true;
}
blog comments powered by Disqus