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

Anyone know how to get the files in one directory?

thanks

Apr 6 '06 #1
2 1738
zjffdu wrote:
thanks


Not without platform specific extensions of brute force.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Apr 6 '06 #2
"zjffdu" <zj****@gmail.com> wrote:
Anyone know how to get the files in one directory?


Yes, I know a bunch of ways. Since I don't know what operating
system(s) you're using, I can't be very specific, but one approach
is to use "system", like this (assumes DOS or Windows; alter as
necessary for Unix, Linux, OS2, Mac, or whatever):

#include <iostream>
#include <fstream>
int SomeFunction(int SomeParameter)
{
// some code
system("dir >> C:\\TEMP\\DIRFILE.TXT"); // make dir file
ifstream IFS("C:\\TEMP\\DIRFILE.TXT"); // open dir file
// read and use contents of dir file
IFS.close(); // close dir file
system("erase C:\\TEMP\\DIRFILE.TXT"); // erase dir file
// some more code
return 0;
}

(For Unix or Linux, replace "dir >> C:\\TEMP\\DIRFILE.TXT" with
"list >> /etc/dirfile.txt" or some such thing.)
Another way, which can be more efficient (but less portable),
is to use the platform-specific C extensions that almost certainly
come with your compiler (whatever that may be), like so:

#include <iostream>
#include <list>
#include <string>
int SomeFunction(int SomeParameter)
{
// some code
std::list<std::string> Blat;
SomePlatformSpecificFunction(Blat); // put list of files in Blat
// read and use list of files in Blat
// some more code
return 0;
}

(Read the documentation for your operating system and your compiler
for more information.)
Hope that gives you some ideas.
--
Robbie Hatley
Tustin, CA, USA
lone wolf intj at pac bell dot net
home dot pac bell dot net slant earnur slant
Apr 6 '06 #3

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

Similar topics

4
by: Lol McBride | last post by:
Hi all, I'm developing an OOP program and trying to be smart by using unittest to help me to catch as many bugs as possible during development.Unfortunately I've hit a snag which I believe is to...
6
by: Skip Montanaro | last post by:
I wrote PEP 304, "Controlling Generation of Bytecode Files": http://www.python.org/peps/pep-0304.html quite awhile ago. The first version appeared in January 2003 in response to questions...
1
by: pointBoarder | last post by:
I'd like to be able to create a table listing all the files in a certain directory... Anyone know how to go about this or where I could look for more information? Thanks for the hand :] Derek
3
by: John B | last post by:
Hi, I'm getting a file not found error - looks like the app is looking for a file called 'fuhnxrfp.dll' or 'fuhnxrfp.exe'. Does anyone know what this file is? I can't find a reference to it...
5
by: spookyu | last post by:
Alright, I'm sure your tired to hearing this but...does anyone know of any GOOD tutorial's for learning c#. The more basic the better, I have NO experience with programing before this other than...
13
by: nigel.t | last post by:
Using linux <?php exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval); ?> or perhaps try it on your system and tell me if it does/doesnt and what your linux is? I've also tried
12
by: Antonio Maschio | last post by:
Hi, I need help. I want to read text files contained into a directory, but my program is unaware of how many files are contained into. In bash there's something similar to (figure out) for i...
63
by: David Mathog | last post by:
There have been a series of questions about directory operations, all of which have been answered with "there is no portable way to do this". This raises the perfectly reasonable question, why,...
7
by: devnew | last post by:
hi i am trying to create a cache of digitized values of around 100 image files in a folder..In my program i would like to know from time to time if a new image has been added or removed from the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.