Solved

Searching the HD in C

Posted on 1997-12-07
3
209 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now