Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   help with folder/file enumeration (http://www.programmingforums.org/showthread.php?t=11569)

waiteg Oct 13th, 2006 1:29 PM

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.

DaWei Oct 13th, 2006 2:06 PM

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.

Polyphemus_ Oct 13th, 2006 2:37 PM

To add something to Dawei's post, here is a link which may help you: Linky-dinky

Eoin Oct 13th, 2006 4:50 PM

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

grumpy Oct 13th, 2006 7:16 PM

Quote:

Originally Posted by waiteg (Post 116422)
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 (Post 116422)
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 (Post 116422)
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.


All times are GMT -5. The time now is 1:11 AM.

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