![]() |
| | #1 |
| Registered User Join Date: May 2009 Location: Baires
Posts: 12
| How to use files in a path? The thing is that I can't find a function to do the following, For example: I have 1.txt, 2.txt, 3.txt in C:\files And I need to work with those files with a program, but i don't know how to read the path and save the file names in an array or something, to use them later. Anyone please help! Thanks!! |
| guriwashere is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Read the path from where? |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: May 2009 Location: Baires
Posts: 12
| A function or something... The main thing is to save the file names in an array or buffer... |
| guriwashere is offline | |
| | #4 |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,262
| But it has to be available to the program somehow. So it's either hard-coded in the source or supplied on stdin. |
| itCbitC is offline | |
| | #5 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Yes, but read the path from where? A file? Hardcoded into your program? Something the user types in? An open file dialog? |
| tabstop is offline | |
| | #6 |
| Registered User Join Date: May 2009 Location: Baires
Posts: 12
| Hardcoded into the program To read always from the same path. Thanks! |
| guriwashere is offline | |
| | #7 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Then you just have to type the path into your program, like Code: const char *filenames[] = {"path\\1", "path\\2"};
|
| tabstop is offline | |
| | #8 |
| Registered User Join Date: May 2009 Location: Baires
Posts: 12
| But the thing is that I won't always know the names of the files, so I need to read all of them, and save the names in an array to use them. |
| guriwashere is offline | |
| | #9 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| But where are you planning to read them from? Do you intend to do a dir/ls/moral equivalent to get a list of the files in the directory, or what? |
| tabstop is offline | |
| | #10 | |
| Registered User Join Date: May 2009 Location: Baires
Posts: 12
| Quote:
I don't care how to do it, I just need that. Sorry for my english, I'm from Argentina | |
| guriwashere is offline | |
| | #11 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| You are interested in the functions opendir(), readdir(), and closedir()
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
| | #12 | |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Quote:
| |
| tabstop is offline | |
| | #13 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,945
| So the path is known? Ie, you could hardcode the path: Code: path[]="/some/place/"; If you have to recurse into the tree, that is more work.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is online now | |
![]() |
| Tags |
| array, file names |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error opening files in a different dir | Ozzie | C++ Programming | 3 | 10-09-2008 06:55 AM |
| Linking header files, Source files and main program(Accel. C++) | Daniel Primed | C++ Programming | 3 | 01-17-2006 11:46 AM |
| Multiple Cpp Files | w4ck0z | C++ Programming | 5 | 11-14-2005 02:41 PM |
| Folding@Home Cboard team? | jverkoey | General Discussions | 398 | 10-11-2005 08:44 AM |
| Batch file programming | year2038bug | Tech Board | 10 | 09-05-2005 03:30 PM |