Saturday, 14 September 2013

Check if file existing or not in c

Check if file existing or not in c

unsigned char IsFilePathCorrect(char* prgchDirPath)
{
WIN32_FIND_DATA FindFileData;
HANDLE handle;
int found=0;
//1. prgchDirPath is char pointer. But expected is LPCWSTR.
//How to change this?
//2. prgchDirPath is a directory path. File is not existed.
//But I want to make sure if directory/path exists or not.
//Can the API below helps me? if yes, how?
handle = FindFirstFile(prgchDirPath, &FindFileData);
if(handle != INVALID_HANDLE_VALUE)
found = 1;
if(found)
{
FindClose(handle);
}
return found;
}
I want to check if directory path is existed or not. Please provide one
sample code. Thank you.

No comments:

Post a Comment