Solved

Searching the HD in C

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

Independent Software Vendors: 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!

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 tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

739 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