This code, not written by me just edited, scans the given directory for mp3's, problem is it only scans that folder. IE if you type c:\ and c:\ had immeadiate mp3s, not in folders, it'll pick them up. How can i alter this code so that when c:\ is enterd it scans all the subfolders also, ie searches the entire hard disk. Heres the code:
Code:#include <windows.h>//For FindFirstFile etc #include <iostream>//For cout etc #include <string>//For...well...ugh...string! using std::string; using std::cout; using std::cin; using std::endl; int main(int argc,char** argv){ WIN32_FIND_DATA wfd;//This holds the data on a found file string str;//To hold directory path int i = 0; cout << "Enter Directory: "; cin>>str;//Get path cout<<"\n"; str += "\\*.mp3*";//Add this to indicate we want mp3 files HANDLE hFile = FindFirstFile(str.c_str(),&wfd);//Find first if(hFile ==INVALID_HANDLE_VALUE){//If error..abort cout << "Error!! Aborting" << endl; return 1; } do{ cout << wfd.cFileName << endl; i++; }while(FindNextFile(hFile,&wfd));//Get the rest of the files cout<<"\nFound "<<i<<" Files.\n"<<endl; FindClose(hFile);//Clean up! return 0; }



LinkBack URL
About LinkBacks


