Click to See Complete Forum and Search --> : searching.. for that one thing I will never find..


thedarkavenger
June 6th, 2002, 03:24 AM
Dear members,,,
i want to know how to write a program which searches the harddrives for a file specified by the user and takes different actions if the file is found or not. It should also print out if it fount the file or not. In other words it should simulate the "dir/s" command in dos.Could somebody tell me how to do it using the inbuilt functions of Turbo C++ or Borland C compiler?
I tried using the find_first, find_next functions but they only searched the directory in which the program was running. I would be really grateful if somebody would send me the program or atleast give me a snippet.
Thanks a lot.

Elrond
June 6th, 2002, 05:45 AM
I don't have any code, but to solve your problem, for each file name you get, you should check if it is a directory. If it is, then you should call the find_first / find_next functions in this directory. If it is a file, just go to the next.

Make it recursive that way will look through all the harddrive.

thedarkavenger
June 6th, 2002, 07:59 AM
Thanks for the prompt reply,
But can u please tell me how to check if it is a directory or hardrive?
Thanks