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);
}
}
}
BuyVM针对中国客户推出了China Special - STREAM RYZEN VPS主机,带Streaming Optimized IP,帮你解锁多平台流媒体,适用于对于海外流媒体有需求的客户,主机开设在拉斯维加斯机房,AMD Ryzen+NVMe磁盘,支持Linux或者Windows操作系统,IPv4+IPv6,1Gbps不限流量,最低月付5加元起,比美元更低一些,现在汇率1加元=0.7...
Megalayer 商家算是比较新晋的国内主机商,主要方向是美国、香港、菲律宾等机房的独立服务器为主,以及站群服务器和显卡服务器。同时也有新增价格并不是特别优惠的VPS云服务器。上午的时候有网友问问有没有CN2线路的美国独立服务器的,这里我推荐他选择Megalayer看看,目前也是有活动截止到月底的。Megalayer 商家创办2年左右时间,如果我们初次使用建议月付体验。目前在进行且可能截止到6月...
racknerd当前对美国犹他州数据中心的大硬盘服务器(存储服务器)进行低价促销,价格跌破眼镜啊。提供AMD和Intel两个选择,默认32G内存,120G SSD系统盘,12个16T HDD做数据盘,接入1Gbps带宽,每个月默认给100T流量,5个IPv4... 官方网站:https://www.racknerd.com 加密数字货币、信用卡、PayPal、支付宝、银联(卡),可以付款! ...