Click here to Skip to main content
15,920,801 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help writing a function Pin
NietzscheDisciple23-Sep-04 12:44
NietzscheDisciple23-Sep-04 12:44 
GeneralRe: Help writing a function Pin
Ravi Bhavnani23-Sep-04 13:31
professionalRavi Bhavnani23-Sep-04 13:31 
GeneralRe: Help writing a function Pin
NietzscheDisciple23-Sep-04 13:45
NietzscheDisciple23-Sep-04 13:45 
GeneralRe: Help writing a function Pin
Ravi Bhavnani23-Sep-04 18:07
professionalRavi Bhavnani23-Sep-04 18:07 
GeneralRecursive File Enumeration Pin
wayvirgo23-Sep-04 11:50
wayvirgo23-Sep-04 11:50 
GeneralRe: Recursive File Enumeration Pin
David Salter23-Sep-04 11:56
David Salter23-Sep-04 11:56 
GeneralRe: Recursive File Enumeration Pin
wayvirgo23-Sep-04 12:08
wayvirgo23-Sep-04 12:08 
GeneralRe: Recursive File Enumeration Pin
BlackDice24-Sep-04 3:20
BlackDice24-Sep-04 3:20 
here's an example using the CFileFind class.

 void MyClass::GetFiles(CString strPath,BOOL bRecurse)
{

	CFileFind finder;
	CString strFile;
	BOOL bWorking = finder.FindFile(strPath + _T("\\*.*"));

	while(bWorking)
	{
		bWorking = finder.FindNextFile();
		if(finder.IsDirectory() && !finder.IsDots() && bRecurse)
		{
			strFile = finder.GetFilePath();
			
			GetFiles(strFile,bRecurse);
		}
		if(!finder.IsDirectory && !finder.IsDots())
		{
			strFile = finder.GetFilePath();
			//this is a file, do something with the string
		}
	}
}

you should be able to use the function like this:
GetFiles("C:\\MyProjects",TRUE);

this should get all the files in that directory and all subdirectories.

to only get the files with one folder, just call with a second parameter of false

[insert witty comment here]

bdiamond Sleepy | :zzz:
QuestionHow about this? Pin
Tom Wright23-Sep-04 11:34
Tom Wright23-Sep-04 11:34 
AnswerRe: How about this? Pin
Michael Dunn23-Sep-04 11:42
sitebuilderMichael Dunn23-Sep-04 11:42 
GeneralRe: How about this? Pin
Tom Wright23-Sep-04 11:50
Tom Wright23-Sep-04 11:50 
GeneralRe: How about this? Pin
BlackDice23-Sep-04 11:59
BlackDice23-Sep-04 11:59 
GeneralRe: How about this? Pin
Tom Wright23-Sep-04 12:04
Tom Wright23-Sep-04 12:04 
GeneralRe: How about this? Pin
Michael Dunn23-Sep-04 12:03
sitebuilderMichael Dunn23-Sep-04 12:03 
GeneralRe: How about this? Pin
Tom Wright23-Sep-04 12:24
Tom Wright23-Sep-04 12:24 
GeneralRe: How about this? Pin
Tom Wright23-Sep-04 12:32
Tom Wright23-Sep-04 12:32 
GeneralRe: How about this? Pin
Michael Dunn23-Sep-04 15:13
sitebuilderMichael Dunn23-Sep-04 15:13 
GeneralRe: How about this? Pin
markkuk23-Sep-04 23:58
markkuk23-Sep-04 23:58 
General_CrtIsValidHeapPointer ASSERTS Pin
BlackDice23-Sep-04 10:43
BlackDice23-Sep-04 10:43 
GeneralRe: _CrtIsValidHeapPointer ASSERTS Pin
Michael Dunn23-Sep-04 11:45
sitebuilderMichael Dunn23-Sep-04 11:45 
GeneralRe: _CrtIsValidHeapPointer ASSERTS Pin
BlackDice23-Sep-04 11:51
BlackDice23-Sep-04 11:51 
GeneralTCHAR pointer character count Pin
Gimpy198323-Sep-04 9:53
Gimpy198323-Sep-04 9:53 
GeneralRe: TCHAR pointer character count Pin
João Paulo Figueira23-Sep-04 10:05
professionalJoão Paulo Figueira23-Sep-04 10:05 
GeneralRe: TCHAR pointer character count Pin
Gimpy198323-Sep-04 10:09
Gimpy198323-Sep-04 10:09 
GeneralRe: TCHAR pointer character count Pin
João Paulo Figueira23-Sep-04 11:06
professionalJoão Paulo Figueira23-Sep-04 11:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.