I want to make a c++ program which scan all drives and generate list of all files and folder.
how can i do it in c++?
Plz help me......
What have you tried so far?
if(ptr=popen("dir /b /-s","r")!=null)
i did it. Using this i am able to generate list of all files and folders of a drive in text file.
But i have two problems
1. I have to changedirectry myself. It does not get drive names itself and generate list.
2. This program is based on command prompt(dir command).
Be warned that scanning a drive for all files and directories will take a while, depending on how much stuff you have on there.
>>Be warned that scanning a drive for all files and directories will take a while, depending on how much stuff you have on there.
On my 500GB SATA-HDD/7200rpm it took a whooping 30mins(I caught up with a sitcom meanwhile). Then I made it multi-threaded, could barely catch 5 minutes of the show. :)
5 minutes still isn't exactly instant though ;)
Also, if the op wants to do this properly then the op should probably not use the DIR system command, but switch to using the
FindFirstFile function :)
>>5 minutes still isn't exactly instant though
I have a bulky C drive, only 1GB ram. C'mon give the poor threads some credit. :P
>>op should probably not use the DIR system command, but switch to using the FindFirstFile function
system()/shell calls, will take centuries if not ages to scan a 500GB HDD, I on the other hand used the FindFirstFile.
Can you provide me some code using findfirst and findnext function.
i know ,i have to use recursion but how i can?
I am not getting it.
Let me give you a hint: You have to recurse until no directories are found. Good Luck.
I know it but how can i write code for it.
It is my confusion.
I know it.
The problem is how can i do it in c.
So can you provide me some code for it?
You seriously need to learn how to use Google and MSDN.
More examples: http://www.google.de/search?source=ig&hl=de&rlz=&=&q=findfirstfile+example&aq=0&aqi=g1&aql=&oq=findfirstfile+e&gs_rfai=