求C/C++ FTP传送多文件 C/S 框架的实例 !!!!

kukuhalu123 2009-12-23 04:10:07
跪求啊
...全文
71 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
冻结 2009-12-23
  • 打赏
  • 举报
回复
google "CFtpFileFind"
do_fork 2009-12-23
  • 打赏
  • 举报
回复
lftp源码 src/MirrorJob.cc
冻结 2009-12-23
  • 打赏
  • 举报
回复
微软MSDN的实例。
如果楼主WIN32下的话。
该做的微软都做了。
我们要做的已经很少了。


// cftpfilefind_class.cpp
// Compile with: /MT /EHsc
#include <afx.h>
#include <afxwin.h>
#include <afxinet.h>
#include <stdio.h>

CWinApp theApp;

int main()
{
if (!AfxWinInit(::GetModuleHandle(NULL), NULL,
::GetCommandLine(), 0))
{
// catastropic error! MFC can't initialize
return -1;
}

// create a session object to initialize WININET library
// Default parameters mean the access method in the registry
// (that is, set by the "Internet" icon in the Control Panel)
// will be used.

CInternetSession sess(_T("MyProgram/1.0"));

CFtpConnection* pConnect = NULL;

try
{
// Request a connection to ftp.microsoft.com. Default
// parameters mean that we'll try with username = ANONYMOUS
// and password set to the machine name @ domain name
pConnect = sess.GetFtpConnection(_T("ftp.microsoft.com"));

// use a file find object to enumerate files
CFtpFileFind finder(pConnect);

// start looping
BOOL bWorking = finder.FindFile(_T("*"));

while (bWorking)
{
bWorking = finder.FindNextFile();
printf_s("%s\n", (LPCTSTR) finder.GetFileURL());
}
}
catch (CInternetException* pEx)
{
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
printf_s("ERROR! %s\n", sz);
pEx->Delete();
}

// if the connection is open, close it
if (pConnect != NULL)
{
pConnect->Close();
delete pConnect;
}

return 0;
}

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧