public static bool CheckFileExists (string rPathName, bool pbIsDir) { bool bReturnCode = false; if(pbIsDir) pbIsDir = false; // Check for trailing backslash. string PathNameString = rPathName; if(CPathNameHelper.HasTrailingBackslash(rPathName)) { Debug.Assert(false); } else { CFileStatus FileStatus = new CFileStatus(); // If it exists // Note: you can't pass a trailing backslash to CFile::GetStatus() if(CFile.GetStatus(PathNameString, FileStatus)) { // If this is a directory if(FileStatus.m_attribute & CFile.directory) { // Otherwise, it exists but it's already a directory! if(pbIsDir) pbIsDir = true; //ASSERT( false ); //// TRACE("WARNING: Expected file, but this is a directory: \"%s\"\n", (string)rPathName); } else { // File exists bReturnCode = true; } } // Otherwise, it doesn't exist. } return bReturnCode; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)