473,395 Members | 2,006 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,395 software developers and data experts.

File/Directory info in C++

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
2 2452
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take...
3
by: Sandman | last post by:
Hello, An html authoring question: What is the correct syntax to write into a root directory "index file" (mainpage file) so it will point to a graphic file located in another directory?...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
16
by: Hans Fredrik Nordhaug | last post by:
I'm trying to write to a file in the current directory - no remote files. The subject says it all - I can add that both the directory and the file is wordwritable. This happens on a (quite good)...
0
by: phil469 | last post by:
I'm having an issue when trying to read a file in a user's homedir from a cgi script. I have a virtual host section in my httpd.conf file which I'll include. The cgi script is a very basic script...
10
by: deciacco | last post by:
I'm writing a command line utility to move some files. I'm dealing with thousands of files and I was wondering if anyone had any suggestions. This is what I have currently: $arrayVirtualFile =...
1
by: sandhyabhavani | last post by:
This article is used to zip a file or directory using vb.net. The classes and method to zip a file is availale in java.io, java.util, java.util.zip class library.To import these you have to add a...
9
by: tdahsu | last post by:
All, I have the following code: for fileTarget in dircache.listdir("directory"): (dirName, fileName) = os.path.split(fileTarget) f = open(fileTarget).readlines() copying = False for i in...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.