Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 13th, 2006, 12:29 PM   #1
waiteg
Newbie
 
Join Date: May 2006
Posts: 1
Rep Power: 0 waiteg is on a distinguished road
Question help with folder/file enumeration

I am trying to add the names of the subfolders within a folder to an array of strings but I am completely stumped as to how to retrieve the names of the subfolders. Any ideas? I would like to perform this operation natively (not managed). Also, I am a bit of a noob here, so could you pose an answer appropriately.

Thanks.
waiteg is offline   Reply With Quote
Old Oct 13th, 2006, 1:06 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Appropriately? Yes. Read your documentation regarding file operations, write some code, and ask for help with the problems. Consider the string class and vectors, as well a C-style strings and arrays. Words like "findfirst" and "findnext" pop into my mind.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 13th, 2006, 1:37 PM   #3
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
To add something to Dawei's post, here is a link which may help you: Linky-dinky
Polyphemus_ is offline   Reply With Quote
Old Oct 13th, 2006, 3:50 PM   #4
Eoin
Hobbyist Programmer
 
Eoin's Avatar
 
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3 Eoin is on a distinguished road
The Boost Filesystem library is an alternative to DaWei's suggestion but you'll need to spend the necessary time to get a handle on the Boost libraries
__________________
Visit my website BinaryNotions.
Eoin is offline   Reply With Quote
Old Oct 13th, 2006, 6:16 PM   #5
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by waiteg View Post
I am trying to add the names of the subfolders within a folder to an array of strings but I am completely stumped as to how to retrieve the names of the subfolders. Any ideas?
Sure. Problem is the sort of operations you describe (eg to get a directory listing) are operating system dependent. As DaWei hinted, the functions a keyword search for findfirst and findnext will find functions to start.

Under unix, the functions to support this ARE named findfirst() and findnext(). Under the win32 API, the functions to support this are named FindFirstFile() and FindNextFile().

Quote:
Originally Posted by waiteg View Post
I would like to perform this operation natively (not managed).
I assume this means you are using "Managed C++", which I assume means you are working on a Microsoft operating system within the .NET environment. So the win32 API is probably a solution for you. But that's just a guess, as I do not use Managed C++.

If by "not managed" you are referring to something different, then see below.
Quote:
Originally Posted by waiteg View Post
Also, I am a bit of a noob here, so could you pose an answer appropriately.
If you read the responses you have received so far, you might have enough to go on.

As a newbie, I would suggest you need to learn how to post a question appropriately. To that end, I suggest reading the sticky post in the C++ forum entitled "How to ask a question" --- it is right at the top of the list of threads.

People who participate in these forums are not mindreaders. If, as you have done, ask a question which is not particularly clear, you can expect unclear answers.
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
returning value from an enumeration angry_asian C++ 14 Jun 29th, 2006 8:06 PM
problem with defining enumeration variable biohazard C++ 2 Feb 17th, 2006 6:01 PM
Passing 'enumeration' values Kilo C# 4 Dec 15th, 2005 1:31 PM
callback example for file/directory enumeration c0ldshadow C++ 1 Jun 10th, 2005 5:41 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC