?
Solved

Searching the HD in C

Posted on 1997-12-07
3
Medium Priority
?
225 Views
Last Modified: 2012-05-04
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
Comment
Question by:lint17
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1256537
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
 
LVL 7

Expert Comment

by:galkin
ID: 1256538
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
 
LVL 1

Accepted Solution

by:
messiah earned 50 total points
ID: 1256539
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question