c ++ wininet ftp上传递归 [英] c++ wininet ftp upload recursion

查看:62
本文介绍了c ++ wininet ftp上传递归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何上传文件夹内部和文件夹内的文件夹。我无法让我的代码工作,但到目前为止。下面的代码可以上传所有第一个文件夹,但没有文件或子文件夹



所以再次......这是



 BOOL CListfilesDlg :: recursion(CString sPath)
{

UpdateData( true );
CString StrPathS = m_editvalue;


UpdateData( false );

HANDLE hFind; // 文件句柄
WIN32_FIND_DATA FindFileData;

TCHAR DirPath [MAX_PATH];
TCHAR FileName [MAX_PATH];
CString fight = StrPathS + \\ + sPath;
_tcscpy(DirPath,战斗);
_tcscat(DirPath, \\ *); // 搜索所有文件
_tcscpy(FileName,sPath);
_tcscat(FileName, \\);

// 找到第一个文件
hFind = FindFirstFile( DirPath,&安培; FindFileData);
if (hFind == INVALID_HANDLE_VALUE) return FALSE;
_tcscpy(DirPath,FileName);

bool bSearch = true ;
while (bSearch){ // 直到我们找到一个条目
if (FindNextFile(hFind,& FindFileData)){

_tcscat(FileName, FindFileData.cFileName);
if ((FindFileData.dwFileAttributes&
FILE_ATTRIBUTE_DIRECTORY)){

FtpCreateDirectory(hIConnect,FindFileData.cFileName) ;



}
}
}

返回 0 ;
}

解决方案

概括地说,你的功能应该是这样的:

 recursion(string pathName)
{
findfirstfile(pathName);
while (更多要处理的条目)
{
if ( filetype是目录&& filename [ 0 ] 等于' 。'
{
string newPath = pathName + \\ + filename;
递归(newPath);
}
else
{
process filename // 复制或转移等。
}
findnextfile()
}
}


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

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;
}

解决方案

In outline your function should be something like:

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()
    }
}


这篇关于c ++ wininet ftp上传递归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆