部分源代码(在vs2010下编译是移植2008的程序)
1.为什么编译后无法读取ftp服务器上的目录?
void CSelfFtpUpDownloaderDlg::UpdateDir()
{
m_lst.ResetContent();
CFtpFileFind ftpfind(pFtpConnection);
BOOL bfind=ftpfind.FindFile(NULL);
while(bfind)
{
bfind = ftpfind.FindNextFile();
CString strpath;
if (!ftpfind.IsDirectory()) //判断是否是目录
{
strpath = ftpfind.GetFileName();
m_lst.AddString(strpath);
}
else
{
strpath = ftpfind.GetFilePath();
m_lst.AddString(strpath);
}
}
}
也不能进入目录
2.为什么能够正常上传但是不能下载?
void CSelfFtpUpDownloaderDlg::OnBnClickedOnDownLoad()
{
// TODO: 在此添加控件通知处理程序代码
CString selfile;
m_lst.GetText(m_lst.GetCurSel(),selfile);
if (!selfile.IsEmpty())
{
CFileDialog file(false,NULL,selfile,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("所有文件(*.*)|*.*|"),this); 
    if(file.DoModal()==IDOK)
{
CString strname;
strname=file.GetFileName();
CString strdir;
    pFtpConnection->GetCurrentDirectory(strdir);
    pFtpConnection->GetFile(selfile,strname);    //下载文件到选定的本地位置
pInternetSession->Close();                   //关闭废弃的会话
this->ConnectFtp();                          //保持持续会话
pFtpConnection->SetCurrentDirectory(strdir);
this->UpdateDir();
    AfxMessageBox(_T("下载成功!"));
}
}
}void CSelfFtpUpDownloaderDlg::OnBnClickedOnUpload()
{
// TODO: 在此添加控件通知处理程序代码
CString str;
CString strname;
CFileDialog file(true,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("所有文件(*.*)|*.*|"),this);
if(file.DoModal()==IDOK)
{
str=file.GetPathName();
strname=file.GetFileName();
}
if(bconnect)
{
CString strdir;
pFtpConnection->GetCurrentDirectory(strdir);
BOOL bput=pFtpConnection->PutFile((LPCTSTR)str,(LPCTSTR)strname);
if(bput){
pInternetSession->Close(); //关闭废弃的会话
this->ConnectFtp();        //保持持续会话
pFtpConnection->SetCurrentDirectory(strdir);
this->UpdateDir();
AfxMessageBox(_T("上传成功!"));
}
}
}