。
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
sparkedhost怎么样?sparkedhost主机。Sparkedhost于2017年7月注册在美国康涅狄格州,2018年收购了ClynexHost,2019年8月从Taltum Solutions SL收购了The Beast Hosting,同年10月从Reilly Bauer收购了OptNode Hosting。sparkedhost当前的业务主要为:为游戏“我的世界”提供服务器、虚拟...
ttcloud怎么样?ttcloud是一家海外服务器厂商,运营服务器已经有10年时间,公司注册地址在香港地区,业务范围包括服务器托管,机柜托管,独立服务器等在内的多种服务。我们后台工单支持英文和中文服务。TTcloud最近推出了新上架的日本独立服务器促销活动,价格 $70/月起,季付送10Mbps带宽。也可以跟进客户的需求进行各种DIY定制。点击进入:ttcloud官方网站地址TTcloud拥有自...
稳爱云(www.wenaiyun.com)是创建于2021年的国人IDC商家,主要目前要出售香港VPS、香港独立服务器、美国高防VPS、美国CERA VPS 等目前在售VPS线路有三网CN2、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。机房采用业内口碑最好香港沙田机房,稳定,好用,数据安全。线路采用三网(电信,联通,移动)回程电信cn2、cn2 gia优质网络,延迟低,速度快。自行封装的...