Wednesday, December 15, 2010

Check whether a file exist in C++

The following code allows you do check whether a particular file exist.

C++ source code. Using Shell API.

=======

BOOL CheckFileExist(LPCTSTR lpszFullPathName)
{
BOOL bResult = FALSE;
SHFILEINFO shfileinfo;
if (SHGetFileInfo(lpszFullPathName, 0, &shfileinfo, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME) != 0) {
// File Exist
bResult = TRUE;
}
return bResult;
}

No comments: