VC实现文件上传下载FTP
//连接ftp服务器void CMyFtpDlg: :OnConnect()
{
UpdateData(TRUE) ;
//新建对话m_pInetSession=new CInternetSession(AfxGetAppName() , 1,PRE_CONFIG_INTERNET_ACCESS) ;try
{
//新建连接对象m_pFtpConnection=m_pInetSession-> GetFtpConnection(m_strServer,m_strUserName,m_strPassword) ;
}catch(CInternetException *pEx)
{
//获取错误
TCHAR szError[1024] ;if(pEx-> GetErrorMessage(szError, 1024) )
AfxMessageBox(szError) ;else
AfxMessageBox( "There was an exception ") ;pEx-> Delete() ;m_pFtpConnection=NULL;return;
}m_pRemoteFinder = new CFtpFileFind(m_pFtpConnection) ;
//获得服务器根目录的所有文件并在列表框中显示
BrowseDir( " ",&m_ctrlRemoteFiles,m_pRemoteFinder,&m_arrRemoteFiles) ;
}
//下载单个文件void CMyFtpDlg: :DownFile(FILEITEM fileItem)
{if(f i leItem.bDir == TRUE)
{
AfxMessageBox( "本程序暂时不支持下载整个文件夹,请选择文件下载") ;
}else
{
//格式化文件名
CString strLocalFile, strRemoteFile;strRemoteFile.Format( "%s\\%s ",m_pRemoteFinder->GetRoot() ,fileItem. strFileName) ;strLocalFile.Format( "%s\\%s ",m_LocalFinder.GetRoot() ,fileItem. strFileName) ;//下载if(m_pFtpConnection-> GetFile(strLocalFile, strLocalFile) )
{
CString strMsg;strMsg.Format( "下载文件%s成功! ",f ileItem. strFileName) ;
AfxMessageBox(strMsg) ;
}
}
}
//上传单个文件void CMyFtpDlg: :UpFile(FILEITEM fileItem)
{if(f i leItem.bDir == TRUE)
{
AfxMessageBox( "本程序暂时不支持上载整个文件夹,请选择文件上载") ;
}else
{
//格式化文件名
CString strLocalFile, strRemoteFile;strRemoteFile.Format( "%s\\%s ",m_pRemoteFinder->GetRoot() ,fileItem. strFileName) ;strLocalFile.Format( "%s\\%s ",m_LocalFinder.GetRoot() ,fileItem. strFileName) ;//上传if(m_pFtpConnection-> PutFile(strLocalFile, strLocalFile) )
{
CString strMsg;strMsg.Format( "上载文件%s成功! ",f ileItem. strFileName) ;
AfxMessageBox(strMsg) ;
}
}
}
georgedatacenter怎么样?GeorgeDatacenter是一家2017年成立的美国商家,正规注册公司(REG: 10327625611),其实是oneman。现在有优惠,有几款特价VPS,基于Vmware。支持Paypal付款。GeorgeDatacenter目前推出的一款美国vps,2核/8GB内存/250GB NVMe空间/2TB流量/1Gbps端口/Vmware/洛杉矶/达拉...
易探云怎么样?易探云香港云服务器比较有优势,他家香港BGP+CN2口碑不错,速度也很稳定。尤其是今年他们动作很大,推出的香港云服务器有4个可用区价格低至18元起,试用过一个月的用户基本会续费,如果年付的话还可以享受8.5折或秒杀价格。今天,云服务器网(yuntue.com)小编推荐一下易探云国内云服务器优惠活动,北京和深圳这二个机房的云服务器2核2G5M带宽低至330.66元/年,还有高配云服务器...
6元虚拟主机是否值得购买?近期各商家都纷纷推出了优质便宜的虚拟主机产品,其中不少6元的虚拟主机,这种主机是否值得购买,下面我们一起来看看。1、百度云6元体验三个月(活动时间有限抓紧体验)体验地址:https://cloud.baidu.com/campaign/experience/index.html?from=bchPromotion20182、Ucloud 10元云主机体验地址:https:...