ftpで検出ファイルを送信し、FTPサーバに格納する


   
   
   
   
  1. BOOL CheckConfig::SendCheckRtWithFtp(CString cSendRtFilePath,CString cSaveName) 
  2.     TCHAR buf[64]={0}; 
  3.     SYSTEMTIME tm
  4.     GetLocalTime(&tm); 
  5.     wsprintf(buf,_T("%.4d%.2d%.2d"),tm.wYear,tm.wMonth,tm.wDay); 
  6.  
  7.     CInternetSession* pSession = new CInternetSession(AfxGetAppName()); 
  8.     CFtpConnection* pConn = NULL; 
  9.     try 
  10.     { 
  11.         pConn = pSession->GetFtpConnection(cFTPHostIP,cFTPUses,cFTPPwd,21); 
  12.     } 
  13.     catch(CInternetException *pEx) 
  14.     { 
  15.         pEx->Delete(); 
  16.         pConn = NULL; 
  17.         if(pConn!=NULL) 
  18.         { 
  19.             pConn->Close(); 
  20.             delete pConn; 
  21.         }//  
  22.  
  23.         return false
  24.     } 
  25.     pConn->SetCurrentDirectory(_T("SysCheckRt")); 
  26.     pConn->CreateDirectory(buf); 
  27.     pConn->SetCurrentDirectory(buf); 
  28.  
  29.     pConn->Remove(cSaveName); 
  30.     pConn->PutFile(cSendRtFilePath,cSaveName,FTP_TRANSFER_TYPE_BINARY); 
  31.  
  32.     if (pConn != NULL) 
  33.     { 
  34.         pConn->Close(); 
  35.         delete pConn; 
  36.     } 
  37.     delete pSession; 
  38.  
  39.     return TRUE;