Recently in write an FTP program, just contact, we have some questions to ask:
MFC GetFtpConnection connection successfully FTP, can already call SetCurrentDirectory and GetCurrentDirectory
Question 1: when writing GetFile, pass in parameters is right, why always program ran in card dead, or going to GetFile, procedure has not moved, for a long time did not return, such as
Source:
Void Personal_Debug: : ConnectFTP ()//connection
{
M_pInetSession=new CInternetSession
(AfxGetAppName (), 1,
PRE_CONFIG_INTERNET_ACCESS);
Try
{
M_pFtpConnection=m_pInetSession - & gt;
GetFtpConnection (_T (" ftp.spreadtrum.com "), _T (" autotestrd "), _T (" auto27test $RD "));
}
The catch (CInternetException * pEx)
{
TCHAR szError [1024].
/* if (pEx - & gt; GetErrorMessage (szError, 1024))
AfxMessageBox (szError);
The else
AfxMessageBox (_T (" There was an exception ")); */
PEx - & gt; The Delete ();
M_pFtpConnection=NULL;
}
}
Void Personal_Debug: : OnBnClickedButton5 ()
{
//TODO: Add your the control notification handler code here
_tcscpy (m_tAllPathParam strLocalINI m_szSModulePath);
_tcscat (m_tAllPathParam strLocalINI, _T (" \ \ Project \ \ Temp \ \ AutoTester ini "));
M_pFtpConnection - & gt; SetCurrentDirectory (_T (" SPRD \ \ Tools \ \ AutoTester "));
//: : DeleteFile (m_tAllPathParam strLocalINI);//the problem 2, this step must be done?
if (! M_pFtpConnection - & gt; GetFile (_T (" AutoTester. Ini "), m_tAllPathParam. StrLocalINI))//question 1: always call returns failure
{
MessageBox (_T (" Sync - Fail "));
Int iTemp=GetLastError ();
StrTemp. The Format (_T (" directory access error, error: % d "), iTemp);
The Log (strTemp);
}
}
Question 2: whether or not GetFile, be sure to local file? I have been the success, such as from the server to download a.t xt to local, local if existing a.t xt will return failure, you need to call deletefile delete local calls again, must do deletefile this step?
The two problems thank the great god
CodePudding user response:
Rename all rightCodePudding user response:
Thank you teacher zhaoThat means GetFile must be "no local file with the same" can only be invoked the correct
Question 1 can help to look at the code where there is a problem why stuck GetFile infinite card dead,,