//
//功能://从ftp上下载文件
//参数说明:
//远程文件路径url:例"ftp://ftp.microsoft.com/developr/adc/index.txt";
//本地文件路径localpath:例"E:\\Debug\\Cache"或"..\\Debug\\Cache"
//
bool GetFTPFile(
const CString ftpurl,
const CString localpath)
{
CString url = ftpurl;
CString locPath = localpath;
//字符串操作,从路径中获取所需字符串
int iIndex = url.ReverseFind('/');
CString filename = url.Right(url.GetLength() - iIndex - 1); //获取所下载的文件名
CString temp = url.Mid(6, url.GetLength() - 6 - filename.GetLength());
iIndex = temp.Find('/');
CString serv = temp.Left(iIndex); //获取服务器名
CString dir = temp.Right(temp.GetLength() - iIndex);
dir.Replace(L"/", L"\\");
dir += filename; //服务器上的路径和文件名
if(locPath.Right(1)!="\\")
locPath += "\\";
locPath += filename; //本地路径和文件名
CInternetSession *pSession = NULL;
CFtpConnecti
mfc ftp文件下载
最新推荐文章于 2018-07-11 15:49:48 发布