|
-
January 23rd, 2007, 06:31 AM
#1
How can i write function that search for file on the disk ?
Hi,
I want to write some application that looking some file name ( "file.exe" or "*.exe" ) on the entire disk.
Can some one help me ?
-
January 23rd, 2007, 06:34 AM
#2
Re: How can i write function that search for file on the disk ?
Take a look at CFileFind class
-
January 23rd, 2007, 06:49 AM
#3
Re: How can i write function that search for file on the disk ?
Please dont cross post the same question you already got an answer here.
Cheers
-
January 23rd, 2007, 06:49 AM
#4
Re: How can i write function that search for file on the disk ?
Here this is how u do it.
Code:
char szPath[MAX_PATH];
BROWSEINFO lpbi;
::ZeroMemory(&lpbi,sizeof(BROWSEINFO));
ITEMIDLIST *folder = ::SHBrowseForFolder(&lpbi);
::SHGetPathFromIDList(folder,szPath);
CFileDialog cd(1,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,NULL,NULL);
cd.DoModal();
CString sFullMask = szPath + CString("\\*.*");
list<string> ldf;
CFileFind finder;
bool bFound;
bFound=finder.FindFile(sFullMask);
while ((bFound))
{
bFound = finder.FindNextFile();
if (!finder.IsDots())
{
// Add file to list
string sName = finder.GetFilePath();
if (finder.IsDirectory()) sName += "\\";
ldf.push_back(sName);
}
}
If u dont want to use string<> u can use some ting else ...
If you found my reply to be useful, please dont hesitate to rate it.
DO NOT kick the Axe if it doesnt fall on your foot.
Salman
-
January 23rd, 2007, 07:02 AM
#5
Re: How can i write function that search for file on the disk ?
Check out this wonderful FAQ
PS: Please do make it a habbit to use the search option.
- Sreehari
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
" Everybody is sent to Earth on a purpose. I am so Lagging behind that i won't die." – Calvin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|