windows FTP上传
TCHAR tcFileName[MAX_PATH * 4] = {L"visio2010永久安装密钥.txt"};
TCHAR tcName[MAX_PATH * 4] = {0};
wcscpy(tcName, AfxGetAppName());
CInternetSession sess(tcName);
CFtpConnection *pFTP = sess.GetFtpConnection(L"192.168.1.87");//FTP服务器地址
TCHAR tcPath[MAX_PATH * 4] = {0};
DWORD dwLength = MAX_PATH * 4;
if(!pFTP->GetCurrentDirectory(tcPath, &dwLength)){
printf("GetCurrentDirectory failed with error %d\n", GetLastError());
}
if(!pFTP->SetCurrentDirectory(L"//")){//根目录,如果需要子目录,在后面添加子目录
printf("SetCurrentDirectory failed with error %d\n", GetLastError());
}
CFtpFileFind ftpfind(pFTP);
while (true){
if(ftpfind.FindFile(tcFileName)){
printf("找到文件\n");
break;
}
}
if(!pFTP->GetFile(tcFileName, L"E:\\visio2010永久安装密钥.txt"), 0){//文件类型要匹配,下载
printf("GetFile failed with error %d\n", GetLastError());
}
if(!pFTP->PutFile(L"E:\\PL-2303 Vista Driver Installer.rar", L"PL-2303 Vista Driver Installer.rar")){
printf("PutFile failed with error %d\n", GetLastError());
}
//CInternetFile *netFile = pFTP->OpenFile(L"FeiQ.1060559168.exe");
//netFile->Write();
sess.Close();
不可以使用在工程中,因为可能有内存泄漏,写得不好。。。
版权声明:本文为博主原创文章,未经博主允许不得转载。

浙公网安备 33010602011771号