pFileFind=NULL;
//UpdateData(TRUE); // 获得用户的当前输入(服务器名,用户名和口令)
// while(m_listFile.GetCount()!=0) m_listFile.DeleteString(0); // 清除列表框的内容
pSession=new CInternetSession( // 创建Internet会话类对象
appName/*AfxGetAppName()*/,1,PRE_CONFIG_INTERNET_ACCESS);
try
{ // 试图建立与指定FTP服务器的连接
pConnection=
pSession->GetFtpConnection(m_strFtp,m_strName,m_strPwd);
} catch (CInternetException* e) {
e->Delete(); // 无法建立连接,进行错误处理
pConnection=NULL;
}
if (pConnection!=NULL)
{// 创建CFtpFileFind对象,向构造函数传递CFtpConnection对象的指针
pFileFind=new CFtpFileFind(pConnection);
bContinue=pFileFind->FindFile("*"); // 查找服务器上当前目录的任意文件
if (!bContinue) // 如果一个文件都找不到,结束查找
{
pFileFind->Close();
pFileFind=NULL;
}
//CString strSName = "d:\\output\\" + filename1; //Media Express Manual.pdf";
//CString strDName = "d:\\input\\" + pathname1 +"\\" + filename1;//"./Media Express Manual.pdf";
CString strSName = "./" + filename1; //Media Express Manual.pdf";
CString strDName = "./" + filename1; //"./Media Express Manual.pdf";
/*pConnection->GetFile(strSName,strDName);*///下载
pConnection->PutFile(strSName, strDName);//上传
if (pFileFind!=NULL)
{
pFileFind->Close(); // 结束查询
pFileFind=NULL;
}
}
delete pFileFind; // 删除文件查询对象
if (pConnection!=NULL)
{
pConnection->Close();
delete pConnection; // 删除FTP连接对象
}
delete pSession; // 删除Internet 会话对象
}
int main()
{
vt_downLoad("3.ts", "123");
return 0;
}
摘自 lingxiu0613的专栏