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);
}
}
}
哪里购买香港云服务器便宜?众所周知,国内购买云服务器大多数用户会选择阿里云或腾讯云,但是阿里云香港云服务器不仅平时没有优惠,就连双十一、618、开年采购节这些活动也很少给出优惠。那么,腾讯云虽然海外云有优惠活动,但仅限新用户,购买过腾讯云服务器的用户就不会有优惠了。那么,我们如果想买香港云服务器,怎么样购买香港云服务器便宜和优惠呢?下面,云服务器网(yuntue.com)小编就介绍一下!我们都知道...
稳爱云(www.wenaiyun.com)是创建于2021年的国人IDC商家,主要目前要出售香港VPS、香港独立服务器、美国高防VPS、美国CERA VPS 等目前在售VPS线路有三网CN2、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。机房采用业内口碑最好香港沙田机房,稳定,好用,数据安全。线路采用三网(电信,联通,移动)回程电信cn2、cn2 gia优质网络,延迟低,速度快。自行封装的...
零途云(Lingtuyun.com)新上了香港站群云服务器 – CN2精品线路,香港多ip站群云服务器16IP/5M带宽,4H4G仅220元/月,还有美国200g高防云服务器低至39元/月起。零途云是一家香港公司,主要产品香港cn2 gia线路、美国Cera线路云主机,美国CERA高防服务器,日本CN2直连服务器;同时提供香港多ip站群云服务器。即日起,购买香港/美国/日本云服务器享受9折优惠,新...