473,396 Members | 1,866 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,396 software developers and data experts.

problem listing files in a directory

hi.
i wrote that code to list the files existed in "c:\" but it doesn't
seem to work cuz when i excute it it dosn't list all the exitsed files
in "c:\"
can someone tell me what's wrong ?
thanks.
#include<stdio.h>
#include<dir.h>

#define FILE_NOT_FOUND (-1)
int main(int argc,char *argv[])
{

_finddata_t finddata;

long hfile;
hfile=_findfirst("c:\*.*",&finddata);
while(_findnext(hfile,&finddata)!= FILE_NOT_FOUND){
printf("%s\n",finddata.name);
}
_findclose(hfile);
getchar();
return 0;
}
Jul 2 '08 #1
3 1458
In article <25**********************************@d45g2000hsc. googlegroups.com>,
Jrdman <ah*********@gmail.comwrote:
hfile=_findfirst("c:\*.*",&finddata);
If you want a string with a backslash in it, you need to use "c:\\*.*".

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Jul 2 '08 #2
On Wed, 2 Jul 2008 05:58:49 -0700 (PDT), Jrdman
<ah*********@gmail.comwrote:
>hi.
i wrote that code to list the files existed in "c:\" but it doesn't
seem to work cuz when i excute it it dosn't list all the exitsed files
in "c:\"
can someone tell me what's wrong ?
thanks.
#include<stdio.h>
#include<dir.h>

#define FILE_NOT_FOUND (-1)
int main(int argc,char *argv[])
{

_finddata_t finddata;

long hfile;
hfile=_findfirst("c:\*.*",&finddata);
If you didn't see a diagnostic here you need to up your warning level
or find a competent compiler. \* is not a valid sequence.
while(_findnext(hfile,&finddata)!= FILE_NOT_FOUND){
printf("%s\n",finddata.name);
}
_findclose(hfile);
getchar();
return 0;
}

Remove del for email
Jul 3 '08 #3
On Jul 2, 5:58 pm, Jrdman <ahmed.bo...@gmail.comwrote:
hi.
i wrote that code to list the files existed in "c:\" but it doesn't
seem to work cuz when i excute it it dosn't list all the exitsed files
in "c:\"
can someone tell me what's wrong ?
thanks.
#include<stdio.h>
#include<dir.h>

#define FILE_NOT_FOUND (-1)
int main(int argc,char *argv[])
{

_finddata_t finddata;

long hfile;
hfile=_findfirst("c:\*.*",&finddata);
while(_findnext(hfile,&finddata)!= FILE_NOT_FOUND){
printf("%s\n",finddata.name);}

_findclose(hfile);
getchar();
return 0;

}
Strictly off-topic, as you are using a particular API which is not
covered by C standards. By the way, either use an escaped '\' or use a
'/'. Windows accepts both '\' and '/' as path separator.
Jul 3 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Wasilewski | last post by:
I created a (real estate) site which has an area that is used by the agent to post and edit property listings. They have the ability here to upload pictures. If the listing is new, it is...
19
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing =...
2
by: Joseph Geretz | last post by:
I'm having a credentialing problem in my web application. Actually, I don't think this is an IIS security issue, since I'm able to access the page I'm requesting. However, the executing page itself...
3
by: Pitcairnia | last post by:
The basic purpose of the site is for authenticated users to post event listings, which often include photographs. The user is faced with a page where they can insert all of the information about...
0
by: Stewart Midwinter | last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item that does nothing more than fetch a directory listing and display it in a Toplevel window (I'd use a tkMessageBox showinfo...
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
0
by: placid | last post by:
Hi all, Im having trouble with the following code for handling GET requests from a client to my HTTP server. What i want to do is restrict access only to a folder and contents(files) within this...
8
by: dougawells | last post by:
Hi - I'm hoping for help with the auto-generation of a hyperlinked listing of all files in a directory. The server I use does not auto-generate this. So, when someone comes to this directory and...
7
by: epikto | last post by:
I have a mapped share that I am trying to get a listing of all the files that it contains. I use the following code to access the contents String files = Directory.GetFiles(path); I can then...
5
by: jain236 | last post by:
HI every body, i am always getting the following error while parsing a directory . i am reading a directory by doing ls and trying to find out the name,type,size, mtime and mode of files from...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.