[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Searching the HD in C

Im trying to write a program that has an automatic config.
I need to get the program to search the HD for a file.. say called rene.bla  and then return its path to a string maybe, so i can use it.  Any ideas?
Thanks!!!!!
0
lint17
Asked:
lint17
1 Solution
 
Tommy HuiCommented:
What you'll need to do is to search each drive. For every drive on the system, start searching at the root. If that file doesn't exist, recursively traverse each subdirectory and look for that file (using findfirst()/findnext()).


0
 
galkinCommented:
You must establish search engine.

// assuming that lpszPathName is path name of the folder(drive) // in your case you must itterate through all hard disk drives // and perform the following code


HANDLE hFile;
WIN32_FIND_DATA FindFileData;

if((hFile = ::FindFirstFile(lpszPathName, &FindFileData))
                              == INVALID_HANDLE_VALUE)
// file not found
else
// file found, you must close search engine
::FindClose(hFile);


0
 
messiahCommented:
Doesnt work.. but you did try pretty good so I still give the points.

I have Borland Turbo C++ v2.0 for DOS.
there were compiler errors all over the place.
thanks

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now