MFC(ftp)

void CTest2Dlg::OnBnClickedButton51()
{
CInternetSession *pCInternetSession = new CInternetSession();
CFtpConnection *pCFtpConnection = pCInternetSession->GetFtpConnection("58.249.123.236", "lzd", "lzd1234", 21);
CFtpFileFind *pCFtpFileFind = new CFtpFileFind(pCFtpConnection);

//upload file
BOOL bResult = pCFtpConnection->PutFile("D:\\ftpFile.txt", "ftpTest\\ftpFile.txt");
if(bResult)
{
   bResult = DeleteFile("D:\\ftpFile.txt");
   if(bResult)
   {
    //download file
    bResult = pCFtpConnection->GetFile("ftpTest\\ftpFile.txt", "D:\\ftpFile.txt");
   }
}

//find all the file on the ftp server
bResult = pCFtpFileFind->FindFile("*");
while(bResult)
{
   bResult = pCFtpFileFind->FindNextFileA();

   CString strFileURL = pCFtpFileFind->GetFileURL();
   CString strFileName = pCFtpFileFind->GetFileName();
   CString strFileTitle = pCFtpFileFind->GetFileTitle();
   CString strFilePath = pCFtpFileFind->GetFilePath();
}

//DWORD dTemp = GetLastError();
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章