。
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
{
//格式化文件名
。1
。
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) ;
}
}
}
。2
。
致力为企业和个人提供合同协议策划案计划书学习资料等等打造全网一站式需求
。3
v5net当前对香港和美国机房的走优质BGP+CN2网络的云服务器进行7折终身优惠促销,每个客户进线使用优惠码一次,额外有不限使用次数的终身9折优惠一枚!V5.NET Server提供的都是高端网络线路的机器,特别优化接驳全世界骨干网络,适合远程办公、跨境贸易、网站建设等用途。 官方网站:https://v5.net/cloud.html 7折优惠码:new,仅限新客户,每人仅限使用一次 9...
酷锐云是一家2019年开业的国人主机商家,商家为企业运营,主要销售主VPS服务器,提供挂机宝和云服务器,机房有美国CERA、中国香港安畅和电信,CERA为CN2 GIA线路,提供单机10G+天机盾防御,提供美国原生IP,支持媒体流解锁,商家的套餐价格非常美丽,CERA机房月付20元起,香港安畅机房10M带宽月付25元,有需要的朋友可以入手试试。酷锐云自开业以来一直有着良好的产品稳定性及服务态度,支...
百星数据(baixidc),2012年开始运作至今,主要提供境外自营云服务器和独立服务器出租业务,根据网络线路的不同划分为:美国cera 9929、美国cn2 gia、香港cn2 gia、韩国cn2 gia、日本cn2 gia等云服务器及物理服务器业务。目前,百星数据 推出的日本、韩国、香港cn2 gia云服务器,2核2G/40G/5M带宽低至60元/月,600元/年。百星数据优惠码:优惠码:30...