问:VC下FTP的访问 请问: VC下如何编程可以访问FTP,并从FTP上读取数据呢? 谢谢大家了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 void CDoHTMLAppDlg::FtpWriteFile(CString strFilePath){ CInternetSession *pInetSession; CFtpConnection *pFtpConnection=NULL; CString strFileName; pInetSession=new CInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS); try { pFtpConnection=pInetSession->GetFtpConnection("10.70.38.109"); } catch(CInternetException *pEx) { char strErrorBuf[255]; pEx->GetErrorMessage(strErrorBuf,255,NULL); AfxMessageBox(strErrorBuf,MB_ICONINFORMATION); pEx->Delete(); pFtpConnection=NULL; goto FinishByDigitalTitan; } strFileName=strFilePath.Mid(strFilePath.ReverseFind('\\')+1); //AfxMessageBox(strFileName,MB_ICONINFORMATION); pFtpConnection->Remove(strFileName); if(pFtpConnection->PutFile(strFilePath,strFileName)!=0) {} else { LPVOID lpMsgBuf; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,0,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&lpMsgBuf,0,NULL); ::MessageBox(0,(LPCTSTR)lpMsgBuf,_T("GetLastError"),MB_OK|MB_ICONINFORMATION); ::LocalFree(lpMsgBuf); }FinishByDigitalTitan: if(pFtpConnection!=NULL) { pFtpConnection->Close(); delete pFtpConnection; } delete pInetSession;} 我刚开始学习网络编程,怎么一执行到Accept 程序就崩溃了? 如何得到文件夹大小? 取别人程序中ListCtrl的数据(例如QQ)一些问题.... 关于显卡的设定 谢谢,anybody1的帮助,请来加分 谁能帮忙解决如下简单问题WINDOWS/MFC冲突 有在杭州下沙喜欢VC的在校大学生吗?进来交个朋友! CComboBox问题! MFC用CFile读取文件问题 数据库大神门,快把你的技术转化为生产力! 如何在一个全局函数中得到主对话框的指针并且调用主对话框类中的成员函数? 在线求IP地址转换问题(50分)
{
CInternetSession *pInetSession;
CFtpConnection *pFtpConnection=NULL;
CString strFileName;
pInetSession=new CInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS);
try
{
pFtpConnection=pInetSession->GetFtpConnection("10.70.38.109");
}
catch(CInternetException *pEx)
{
char strErrorBuf[255];
pEx->GetErrorMessage(strErrorBuf,255,NULL);
AfxMessageBox(strErrorBuf,MB_ICONINFORMATION); pEx->Delete();
pFtpConnection=NULL;
goto FinishByDigitalTitan;
}
strFileName=strFilePath.Mid(strFilePath.ReverseFind('\\')+1);
//AfxMessageBox(strFileName,MB_ICONINFORMATION);
pFtpConnection->Remove(strFileName);
if(pFtpConnection->PutFile(strFilePath,strFileName)!=0)
{}
else
{
LPVOID lpMsgBuf;
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,0,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&lpMsgBuf,0,NULL);
::MessageBox(0,(LPCTSTR)lpMsgBuf,_T("GetLastError"),MB_OK|MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
FinishByDigitalTitan:
if(pFtpConnection!=NULL)
{
pFtpConnection->Close();
delete pFtpConnection;
}
delete pInetSession;
}