DIGIT-ARC read-only archive · snapshot: July 23, 2026

School Computer Project.. searching directories?

6 posts · originally from https://geek.digit.in/community/threads/school-computer-project-searching-directories.122738/

K
karmanya Original post #1
Nov 23, 2009 at 6:12 AM
Hey,
Im in class 12 right now (read : excuse for my inactivity) and I thought that for my board project, I'd end up making an ebook library, mostly because I really need one. One of the things that I need this program to do is to search/scan the computer for all pdf,lit,txt,doc etc etc files (a la, Mediamonkey or iTunes) and write their names and paths to a file. Now I'm pretty sure I can use normal fstream for the writing bit, but I can't find a function to search the computer- findnext and findfirst (from the turbo c++ help files) don't search sub-directories within the ones that i specify for example if i were to say search C:\ it won't look up C:\docs.
Is there anyway around this?
harryneopotter
Nov 23, 2009 at 1:32 PM
Write a Function which takes a directory path ("C:\", or C"\Docs") as argument and then scans the directory and get a list of all the subdirectories. Then recursively call the same function for each of the subdirectories found.

this method will do IMO !!

Example Code:

Void search(string path)
{
..... use ur code to search for subdirectories.....
and then for each of the subdirectories found .....

search(subdirectory);

.......
....
}
-----------------------------------------
Posted again:
-----------------------------------------
Write a Function which takes a directory path ("C:\", or C"\Docs") as argument and then scans the directory and get a list of all the subdirectories. Then recursively call the same function for each of the subdirectories found.

this method will do IMO !!

Example Code:

Void search(string path)
{
..... use ur code to search for subdirectories.....
and then for each of the subdirectories found .....

search(subdirectory);

.......
....
}
G
Nov 23, 2009 at 1:56 PM
write a progam to genrate sine wave
K
Nov 24, 2009 at 9:09 PM
@harryneopotter Erm, how exactly do i scan for directories? Since find_next and find_first don't even pick them up.
vandit
vandit #5
Dec 28, 2009 at 12:27 PM
*www.devarticles.com/c/a/Cplusplus/Directories-in-Cplusplus/2/

this might be of some help. And I recollect there is some funtion by a similar name to what you said.. sorry dont have the access to turbo c manuals currently..
A
Dec 28, 2009 at 8:21 PM
run command line dir *.txt *.pdf /s >new.txt from c.