By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

File/Directory info in C++

P: n/a
Hello,

I've come across a problem and I am hoping that somebody can help me.
Here is what I'd like to do:

I would like to have a bunch of images and subdirectories in a certain
directory (I know where the directory is with respect to where the
program is running), and I want to be able to find out what the names
of all of the images and subdirectories are from within my c++ program.

Has anybody come across this before? Any help would be greatly
appreciated.

Thanks,
Ben

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
bw****@gmail.com wrote in message news:<11*********************@o13g2000cwo.googlegr oups.com>...
Hello,

I've come across a problem and I am hoping that somebody can help me.
Here is what I'd like to do:

I would like to have a bunch of images and subdirectories in a certain
directory (I know where the directory is with respect to where the
program is running), and I want to be able to find out what the names
of all of the images and subdirectories are from within my c++ program.

Has anybody come across this before? Any help would be greatly
appreciated.

Thanks,
Ben


hello friend

to get info about directories u can use the keyword system
i have used it in c but not in c++
i think it will work

eg system("dir>>txt");
u can try;
Jul 23 '05 #2

P: n/a
This is probably the direction you want to go in:
****dir is the string that is the root directory

doEntry(string dir)
{
WIN32_FIND_DATA findData;
HANDLE hFind=FindFirstFile((dir+"\\*.*").c_str(), &findData);
do
{
string sFileName(findData.cFileName);
LPCSTR lp(sFileName.c_str());
if(sFileName == "." || sFileName == "..")
{
//Do Nothing
}
else if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
//Do something with the directory
doEntry(dir+"\\"+sFileName);
}
else
//Do something with file
}while (FindNextFile(hFind, &findData));
}

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.