设为首页 加入收藏

TOP

在VC中实现FTP功能(二)
2014-11-23 20:17:52 】 浏览:551
Tags:实现 FTP 功能
on=NULL; //初始化

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的专栏

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇VC如何制作启动动画 下一篇vc获得网卡流量信息

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目