472,980 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How do you get a list of files currently in a directory??

I have a program which saves time stamped files into time stamped
directories.

When I want to read these files, I get the current date and check for the
existence of the directory using....

while (!(_chdir(dirname)) == 0)
{reduce the directory name (time) and check again}

This method quickly finds the last directory but I don't know anything about
the contents of the directory.

I thought it would be easy to load the contents of this directory into a
list which could be used to open files.
I have been using dir command for years and took it for granted that there
is a function to read directory contents but I can't seem to find any easy
way to do this.

How can directory contents be read?
Is there a function or class?
The only thing I can think of is to write the filenames to a database as
they are being written and then check for their existence in a directory.

Any ideas would be appreciated.
Bob
Feb 28 '06 #1
2 2077
Rob_S wrote:
I have a program which saves time stamped files into time stamped
directories.

When I want to read these files, I get the current date and check for the
existence of the directory using....

while (!(_chdir(dirname)) == 0)
{reduce the directory name (time) and check again}

This method quickly finds the last directory but I don't know anything
about the contents of the directory.

I thought it would be easy to load the contents of this directory into a
list which could be used to open files.
I have been using dir command for years and took it for granted that there
is a function to read directory contents but I can't seem to find any easy
way to do this.

How can directory contents be read?
Is there a function or class?


Not in standard C++. The _chdir() function you're using above isn't a
standard C++ function either. So you have to resort to system-specific
functions (For a POSIX compliant system, they would e.g. be opendir(),
readdir(), closedir()), which are best discussed in a newsgroup about the
operating system/compiler/library you are using.

Feb 28 '06 #2

Rolf Magnus wrote:
Rob_S wrote:

How can directory contents be read?
Is there a function or class?


Not in standard C++. The _chdir() function you're using above isn't a
standard C++ function either. So you have to resort to system-specific
functions


Or a portable library, like boost::filesystem. (Which is mostly
off-topic here,
but www.boost.org has enough documentation).
See also the FAQ about the standard library and non-standard libraries.

HTH,
Michiel Salters

Mar 1 '06 #3

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

Similar topics

5
by: Ken | last post by:
I currently have a set of documents in a directory that i need to list in a html table. Is there any way to generate the table with the documents listed instead of having to update the table...
11
by: Madison Kelly | last post by:
Hi all, I am new to the list and I didn't want to seem rude at all so I wanted to ask if this was okay first. I have a program I have written in perl which uses a postgresSQL database as the...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
4
by: thoseion | last post by:
Hi, I am trying to get a program working whereby directory and file names are read into a list. I have been given the original list structure - it appears that the directory names should be added...
96
by: zzbbaadd | last post by:
What's with the index() function of lists throwing an exception on not found? Let's hope this is rectified in Python 3. If nothing else, add a function that doesn't throw an exception. There are a...
6
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
3
by: froditus | last post by:
Hello everyone, is it possible to list files from directory other than in apache web directory? my web folder is placed on c:/ and i put my files in windows directory "d:/files/images/". I...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
1
by: Trevor17 | last post by:
Hello All, I am currently in a Perl programming class and our assignment was: Create a filehandle with the open function that uses a pipe to list all the files in your current directory and...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.