473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Dump Directory

I have many directorys and many files in each of them.
I want to write a C program to read all these files and extract some important words inside them out. But there is a problem

How can I access a directory in C program ?
How can I change the directory to another directory ?

How to get all the files' name in a specific directory ?

Please help me.
I really need your great help.
Sep 17 '06 #1
3 1713
Refer to dir.h and there you will get all the functionalities you needed.
Sep 18 '06 #2
smk
4
Hi,

Using FindFirstFile and FindNextFile functions you can browse through the directory tree and can get all the files names. These functions will return WIN32_FIND_DATA structure, which has the information about the file attributes.The below example will be helpfull.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. #include "windows.h"
  4.  
  5. int
  6. main(int argc, char *argv[])
  7. {
  8.   WIN32_FIND_DATA FindFileData;
  9.   HANDLE hFind;
  10.  
  11.   printf ("Target file is %s.\n", argv[1]);
  12.  
  13.   hFind = FindFirstFile(argv[1], &FindFileData);
  14.  
  15.   if (hFind == INVALID_HANDLE_VALUE) {
  16.     printf ("Invalid File Handle. Get Last Error reports %d\n", GetLastError ());
  17.   } else {
  18.     printf ("The first file found is %s\n", FindFileData.cFileName);
  19.     FindClose(hFind);
  20.   }
  21.  
  22.   return (0);
  23. }
  24.  
  25.  
Sep 18 '06 #3
Thank you very much !
Really big help !
Sep 18 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
8
by: Alex | last post by:
Hi, I have a test system that is setup the same as a production system and would like to frequently copy the database over. pg_dump takes a few hours and even sometimes hangs. Are there any...
6
by: John Liu | last post by:
I've two questions, they may or may not be related - 1. I copied the entire data directory from postgreSQL 7.3.2 (AIX4.3) to the installation postgreSQL 7.3.4 (AIX5.1), the same filesystem setup....
2
by: Jason Gyetko | last post by:
I have a bunch of old *.000 files in the \SQLLIB\DB2 directory. Those are just dump files that I can get rid of with no effect to the system, right?
9
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug...
7
by: Cyril VELTER | last post by:
I'm trying to dump a database from a 7.1.3 server to a 7.4.2 one. It doesn't works because of difference in COPY format (unless I use -d which is VERY slow on a 16G database). What are the...
6
by: Soeren Gerlach | last post by:
Hi, some weeks ago I started to develop an application using Postgresql the first time. I'm running 7.4.3 on a Linux box with a plain 2.6.7 kernel, the storage is handled by 5 SATA disks,...
1
by: Rotzooi | last post by:
Hi, How can I dump (or verify, VS2005 VB.Net preferred) if an incoming message contains a valid e-mailaddress or alias? I can verify the primary e-mail address from the Active Directory using...
7
by: Just_a_fan | last post by:
I have a program which runs fine here (created in VB9). I publish it to my web site for download & install. It runs on some computers (one or two) but not others. When it does not run, it causes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.