Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing a file in a directory.

Posted on 1999-07-13
2
Medium Priority
?
195 Views
Last Modified: 2011-09-20
I use CBuilder3. In a directory full of image files, how would I loop through this directory extracting each file by path name.
0
Comment
Question by:Right
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 400 total points
ID: 1199973
Simply use the following:

WIN32_FIND_DATA w32fd;
HANDLE hFind;

hFind = FindFirstFile ( "c:\\yourpath\\*.gif", &w32fd);

if ( INVALID_HANDLE_VALUE == hFind)
{
 // error
}
DoSomethingWithFile ( w32fd.cFileName);

while ( FindNextFile ( hFind, &w32fd))
{
  DoSomethingWithFile ( w32fd.cFileName);
}

if ( ERROR_NO_MORE_FILES != GetLastError()))
{
 // error
}
FindClose ( hFind);

Feel free to ask if you need more information!
0
 
LVL 86

Expert Comment

by:jkr
ID: 2031145
comment
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question