GetFileAttributes() returns -1 if the file does not exist, and does NOT require a handle to an open file.

Similarily, _access() also does this.

if(_access (FileName, mode) != -1)

{ ...}

 

FindFirstFile() and FindNextFile() will work, but takes more resources and is more time consuming.

The standard FILE functions, e.g. fopen(), CFile class, and the streams classes also work, but they are normally used when you want to open the file for either read or write.

相關文章