Please Help : Urgent

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2009
Posts: 10
Reputation: Ashishinani1756 has a little shameless behaviour in the past 
Solved Threads: 0
Ashishinani1756 Ashishinani1756 is offline Offline
Newbie Poster

Please Help : Urgent

 
0
  #1
18 Days Ago
help me in listing file names inside directory by using a simple code in c++ that a beginner can understand
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 344
Reputation: dkalita will become famous soon enough dkalita will become famous soon enough 
Solved Threads: 50
dkalita's Avatar
dkalita dkalita is offline Offline
Posting Whiz
 
0
  #2
18 Days Ago
Last edited by dkalita; 18 Days Ago at 7:57 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: skp888 is an unknown quantity at this point 
Solved Threads: 0
skp888 skp888 is offline Offline
Newbie Poster

windows files enumeration

 
0
  #3
18 Days Ago
Originally Posted by Ashishinani1756 View Post
help me in listing file names inside directory by using a simple code in c++ that a beginner can understand
i believe that enumerating files/directories is OS dependent. so assuming your on windows, here are a few code snippets that will help you find files in a directory. the functions are defined in <windows.h>

WIN32_FIND_DATA fileData;
HANDLE hFind = FindFirstFile("C:\WINDOWS\*.exe", &fileData);

this will get the first .exe file that it can find in C:\WINDOWS, and fill the file's information into fileData

FindNextFile(hFind, &fileData)

calling this function will then get the next file matching that pattern. FindNextFile(...) will return NULL when it cant find anymore files.

note that subdirectories are sorta considered files, so will also be returned if they match the pattern (eg you use "C:\WINDOWS\*"), so you can check what is a directory (ie not a file) with:

fileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY

so, using these functions in a simple do-while loop will cycle through every file or subdirectory in a particular folder
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC