VC实现文件上传下载FTP
//连接ftp服务器void CMyFtpDlg: :OnConnect()
{
UpdateData(TRUE);
//新建对话m_pInetSession=new CInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS);try
{
//新建连接对象m_pFtpConnection=m_pInetS es s ion->GetFtpConnec tion(m_strS erver,m_strUs erName,m_strPas sw ord);
}c atch(CInternetExc eption *pEx)
{
//获取错误
TCHAR szError[1024];if(pEx->GetErrorMes s age(szError,1024))
AfxMes sageBox(szError);els e
AfxMessageBox( "There was an exception");pEx->Delete();m_pFtpConnection=NULL;r eturn;
}m_pRemoteFinder = new CFtpFileFind(m_pFtpConnection);
//获得服务器根目录的所有文件并在列表框中显示
Brow s eDir( " ",&m_ctrlRemoteFiles,m_pRemoteFinder,&m_arrRemoteFiles);
}
//下载单个文件void CMyFtpDlg: :DownFile(FILEITEM fileItem)
{if(fileItem.bDir == TRUE)
{
AfxMessageBox( "本程序暂时不支持下载整个文件夹,请选择文件下载");
}els e
{
//格式化文件名
CString strLocalFile,strRemoteFile;s trRemoteF ile.F ormat( "%s\\%s ",m_pRemoteF inder->GetRoot(),fileItem.s trF ileName);strLoc alFile.Format( "%s\\%s ",m_Loc alFinder.GetRoot(),fileItem.strFileN ame);//下载if(m_pFtpConnec tion->GetFile(strLoc alF ile,strLoc alFile))
{
CString strMsg;strMsg.Format( "下载文件%s成功! ",fileItem.strFileName);
AfxMes sageBox(strMsg);
}
}
}
//上传单个文件void CMyFtpDlg: :UpFile(FILEITEM fileItem)
{if(fileItem.bDir == TRUE)
{
AfxMessageBox( "本程序暂时不支持上载整个文件夹,请选择文件上载");}els e
{
//格式化文件名
CString strLocalFile,strRemoteFile;s trRemoteF ile.F ormat( "%s\\%s ",m_pRemoteF inder->GetRoot(),fileItem.strF ileName);strLoc alFile.Format( "%s\\%s ",m_Loc alFinder.GetRoot(),fileItem.strFileN ame);//上传if(m_pFtpConnec tion->PutFile(strLoc alFile,strLoc alFile))
{
CString strMsg;strMsg.Format( "上载文件%s成功! ",fileItem.strFileName);
AfxMes sageBox(strMsg);
}
}
}
Hostadvice主机目录对我们的服务进行了测试,然后给PQ.hosting颁发了十大WordPress托管奖。为此,宣布PQ.Hosting将在一周内进行折扣优惠,购买和续订虚拟服务器使用优惠码:Hostadvice ,全部优惠10%。PQ.hosting,国外商家,成天于2019年,正规公司,是全球互联网注册商协会 RIPE 的成员。主要是因为提供1Gbps带宽、不限流量的基于KVM虚拟的V...
SugarHosts糖果主机商我们较早的站长们肯定是熟悉的,早年是提供虚拟主机起家的,如今一直还在提供虚拟主机,后来也有增加云服务器、独立服务器等。数据中心涵盖美国、德国、香港等。我们要知道大部分的海外主机商都只提供Linux系统云服务器。今天,糖果主机有新增SugarHosts夏季六折的优惠,以及新品Windows云服务器/云VPS上线。SugarHosts Windows系统云服务器有区分限制...
Virmach 商家算是比较久且一直在低价便宜VPS方案中玩的不亦乐乎的商家,有很多同时期的商家纷纷关闭转让,也有的转型到中高端用户。而前一段时间也有分享过一次Virmach商家推出所谓的一次性便宜VPS主机,比如很低的价格半年时间,时间到服务器也就关闭。这不今天又看到商家有提供这样的产品。这次的活动产品包括圣何塞和水牛城两个机房,为期六个月,一次性付费用完将会取消,就这么特别的产品,适合短期玩玩...