Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do I upload folders that have folders inside and files inside also. I cannot get my code to work but here it is so far. This code below works to upload all the first folders, but no files or subfolders

so again..here it is

C++
BOOL CListfilesDlg::recursion(CString sPath)
{

	UpdateData(true);
	CString StrPathS = m_editvalue;
	

	UpdateData(false);

	HANDLE hFind;    // file handle
   WIN32_FIND_DATA FindFileData;
 
   TCHAR DirPath[MAX_PATH];
   TCHAR FileName[MAX_PATH];
 CString fight = StrPathS + "\\" + sPath;
   _tcscpy(DirPath,fight);
   _tcscat(DirPath,"\\*");    // searching all files
   _tcscpy(FileName,sPath);
   _tcscat(FileName,"\\");
 
   // find the first file
   hFind = FindFirstFile(DirPath,&FindFileData);
   if(hFind == INVALID_HANDLE_VALUE) return FALSE;
   _tcscpy(DirPath,FileName);
 
   bool bSearch = true;
   while(bSearch) {    // until we find an entry
     if(FindNextFile(hFind,&FindFileData)) {
        
         _tcscat(FileName,FindFileData.cFileName);
         if((FindFileData.dwFileAttributes &
            FILE_ATTRIBUTE_DIRECTORY)) {
				
				FtpCreateDirectory(hIConnect,FindFileData.cFileName);
				
			

		 }
	 }
   }

	return 0;
}
Posted
Updated 20-Jul-13 22:29pm
v4

1 solution

In outline your function should be something like:
C++
recursion(string pathName)
{
    findfirstfile(pathName);
    while (more entries to process)
    {
        if (filetype is directory && filename[0] not equal '.')
        {
            string newPath = pathName + "\\" + filename;
            recursion(newPath);
        }
        else
        {
            process filename // copy or transfer etc.
        }
        findnextfile()
    }
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900