JAI SINGH
JAI SINGH

Reputation: 27

Search File in a directory

How to find a specific file in a directory or folder?

I just have made a function and trying to pass directory path and file to be searched

BOOL CCalibrTreeView :: SearchFile(const CString &directory,const CString &filename)
{
    CFileFind finder;
}

I just want if file is there in the directory then return true else return false.

Upvotes: 0

Views: 239

Answers (1)

Himanshu
Himanshu

Reputation: 4395

If you need to find specific file, you can use

CString strPath =_T("C:\\abc.txt");
if(PathFileExists(strPath)) // pass full path
{
 //file exists
}
else
{
 //file not exists
}

if file exists it will return true else it will return false.

PathFileExists function
Determines whether a path to a file system object such as a file or folder is valid or not.

Upvotes: 2

Related Questions