预览加载中,请您耐心等待几秒...
1/2
2/2

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

VC实现文件上传下载(FTP)//连接ftp服务器voidCMyFtpDlg::OnConnect(){UpdateData(TRUE);//新建对话m_pInetSession=newCInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS);try{//新建连接对象m_pFtpConnection=m_pInetSession->GetFtpConnection(m_strServer,m_strUserName,m_strPassword);}catch(CInternetException*pEx){//获取错误TCHARszError[1024];if(pEx->GetErrorMessage(szError,1024))AfxMessageBox(szError);elseAfxMessageBox("Therewasanexception");pEx->Delete();m_pFtpConnection=NULL;return;}m_pRemoteFinder=newCFtpFileFind(m_pFtpConnection);//获得服务器根目录的所有文件并在列表框中显示BrowseDir("",&m_ctrlRemoteFiles,m_pRemoteFinder,&m_arrRemoteFiles);}//下载单个文件voidCMyFtpDlg::DownFile(FILEITEMfileItem){if(fileItem.bDir==TRUE){AfxMessageBox("本程序暂时不支持下载整个文件夹,请选择文件下载");}else{//格式化文件名CStringstrLocalFile,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)){CStringstrMsg;strMsg.Format("下载文件%s成功!",fileItem.strFileName);AfxMessageBox(strMsg);}}}//上传单个文件voidCMyFtpDlg::UpFile(FILEITEMfileItem){if(fileItem.bDir==TRUE){AfxMessageBox("本程序暂时不支持上载整个文件夹,请选择文件上载");}else{//格式化文件名CStringstrLocalFile,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)){CStringstrMsg;strMsg.Format("上载文件%s成功!",fileItem.strFileName);AfxMessageBox(strMsg);}}}