i have the code that will search for a file, but i don't want it to search in only 1 directory, i want it to search through the entire computer.
anyone have any code?
Printable View
i have the code that will search for a file, but i don't want it to search in only 1 directory, i want it to search through the entire computer.
anyone have any code?
Log C: and every time the FindFirst/Next returns a directory, so search that, you could write a recursive searcher to do so, i.e. search C: if the first it finds is a directory called Alpha, so search c:\Alpha and so on.
If you don't know how to detect if a file is a directory or not, part 3 of my searching tutorial covers it.
okay thanks. heres what i have so far
Code:WIN32_FIND_DATA FileData;
HANDLE hSearch;
DWORD dwAttrs;
char szDirPath[] = "c:\\TEXTRO\\";
char szNewPath[MAX_PATH];
char szHome[MAX_PATH];
BOOL fFinished = FALSE;
hSearch = FindFirstFile("C:\\*.*", &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
cout<<"no files found";
return;
}
while (!fFinished)
{
cout<< FileData.cFileName<<endl;
if (!FindNextFile(hSearch, &FileData))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
cout<<"no more files\n";
fFinished = TRUE;
}
else
{
cout<<"couldnt find next file";
return;
}
}
}
FindClose(hSearch);
what i really want is something like the dos "tree" command