CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2001
    Posts
    87

    searching.. for that one thing I will never find..

    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.

  2. #2
    Join Date
    Oct 2001
    Location
    Dublin, Eire
    Posts
    880
    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.
    Elrond
    A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
    -- George Steiner

  3. #3
    Join Date
    Oct 2001
    Posts
    87
    Thanks for the prompt reply,
    But can u please tell me how to check if it is a directory or hardrive?
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured