- BOOL CheckConfig::SendCheckRtWithFtp(CString cSendRtFilePath,CString cSaveName)
- {
- TCHAR buf[64]={0};
- SYSTEMTIME tm;
- GetLocalTime(&tm);
- wsprintf(buf,_T("%.4d%.2d%.2d"),tm.wYear,tm.wMonth,tm.wDay);
- CInternetSession* pSession = new CInternetSession(AfxGetAppName());
- CFtpConnection* pConn = NULL;
- try
- {
- pConn = pSession->GetFtpConnection(cFTPHostIP,cFTPUses,cFTPPwd,21);
- }
- catch(CInternetException *pEx)
- {
- pEx->Delete();
- pConn = NULL;
- if(pConn!=NULL)
- {
- pConn->Close();
- delete pConn;
- }//断开链接
- return false;
- }
- pConn->SetCurrentDirectory(_T("SysCheckRt"));
- pConn->CreateDirectory(buf);
- pConn->SetCurrentDirectory(buf);
- pConn->Remove(cSaveName);
- pConn->PutFile(cSendRtFilePath,cSaveName,FTP_TRANSFER_TYPE_BINARY);
- if (pConn != NULL)
- {
- pConn->Close();
- delete pConn;
- }
- delete pSession;
- return TRUE;
- }
转载于:https://blog.51cto.com/venglu/1185221