Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6
Hi All
 

i want to know that this code return me by doing directory scanning from directory that next file is present am using bool which give me presence of file with signal 1.
i want to write the names of files how
 
  CFileFind find;
	    CString path="C:\\TestFile";
	    if(path.Right(1) != "\\")
     	path += "\\";
     	path += "*.txt*";
  	    BOOL found = find.FindFile(path);
	    while (found)
		{
		found = find.FindNextFile();
         // here i need name of file also how to get the name of file 
		if(find.IsDots())
			continue;
		}
here
 
found is bool it scan the directory and run the loop untill files are available
 
i want to write the names of files also how to do that then i have to use the name of file further
 
plz help
Posted 9-May-12 20:51pm
prog786374
Comments
enhzflep at 10-May-12 2:17am
   
Well, since you are using a an instance of the CFileFind class - 'find', you can msdn CFileName for an explanation of it's member functions. One of these will surely return the name of the current file. - it does! GetFileName(), of all things.. It's a CString that is returned.
 
You may choose to use a vector of CStrings to hold the list of matching filenames.
i.e
vector matchingFiles;
found = find.FindNextFile();
// When you get a CString of the cur filename matching *.txt*, save it
matchingFiles.push_back(found.GetFileName());
Peter_in_2780 at 10-May-12 2:57am
   
That's an answer, not a comment. Promote it
Chuck O'Toole at 10-May-12 2:59am
   
How can you possibly be using some members of the CFileFind Class (FindFile(), FindNextFile()) without knowing / looking up the other class members? Is this code something you just cut / pasted from the web somewhere? Double-Click on CFileFind (to highlight it) and hit "F1". Read the displayed documentation.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Well, since you are using a an instance of the CFileFind class - 'find', you can msdn CFileName for an explanation of it's member functions. One of these will surely return the name of the current file. - it does! GetFileName(), of all things.. It's a CString that is returned.
 
You may choose to use a vector of CStrings to hold the list of matching filenames.
i.e
vector matchingFiles;
found = find.FindNextFile();
// When you get a CString of the cur filename matching *.txt*, save it
matchingFiles.push_back(found.GetFileName());
 
And yeah, what Chuck said.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 250
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 DamithSL 125
4 Afzaal Ahmad Zeeshan 120
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 10 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100