新手求助:
最近在写一个FTP相关的程序,刚接触,有一些问题请教:
MFC,GetFtpConnection连接成功FTP后,已经可以调用SetCurrentDirectory和GetCurrentDirectory
问题1:写GetFile时,确定传进去的参数是对的,为什么总是程序跑进去卡死掉,就是跑到GetFile时,程序一直不动了,等了很久都没有返回。源码:
void Personal_Debug::ConnectFTP()//连接
{
m_pInetSession=new CInternetSession (AfxGetAppName(),1, PRE_CONFIG_INTERNET_ACCESS); try { m_pFtpConnection=m_pInetSession-> GetFtpConnection(_T("ftp.spreadtrum.com"),_T("autotestrd"),_T("auto27test$RD")); } catch(CInternetException *pEx) { TCHAR szError[1024]; /*if(pEx->GetErrorMessage(szError,1024)) AfxMessageBox(szError); else AfxMessageBox(_T("There was an exception"));*/ pEx->Delete(); m_pFtpConnection=NULL; }}
void Personal_Debug::OnBnClickedButton5()
{
// TODO: Add your control notification handler code here
_tcscpy(m_tAllPathParam.strLocalINI, m_szSModulePath);
_tcscat(m_tAllPathParam.strLocalINI, _T("\\Project\\Temp\\AutoTester.ini"));
m_pFtpConnection->SetCurrentDirectory(_T("SPRD\\Tools\\AutoTester"));
//::DeleteFile(m_tAllPathParam.strLocalINI);  //问题2,这一步是否一定要做?
if (!m_pFtpConnection->GetFile(_T("AutoTester.ini"),m_tAllPathParam.strLocalINI))//问题1:一直调用返回失败
{
MessageBox(_T("Sync - Fail"));
int iTemp = GetLastError();
strTemp.Format(_T("目录获取出错,error:%d"),iTemp);
Log(strTemp);
}}
问题2:是否GetFile时,一定要确定本地没有文件? 我曾经调成功过,比如从服务器上下载a.txt到本地,本地如果已经存在a.txt就会返回失败,需要调用deletefile删掉本地的再调用,是否一定要做deletefile这一步?就这两个问题谢谢大神们了