首页 > 代码库 > CFtpFileFind例子
CFtpFileFind例子
#include <afx.h>#include <afxwin.h>#include <afxinet.h>#include <stdio.h>// compile for release with// cl /MT /GX// or for debug with// cl /MTd /GXCWinApp theApp;void main(){ if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // catastropic error! MFC can‘t initialize return; } // 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\n", (LPCTSTR) finder.GetFileURL()); } } catch (CInternetException* pEx) { TCHAR sz[1024]; pEx->GetErrorMessage(sz, 1024); printf("ERROR! %s\n", sz); pEx->Delete(); } // if the connection is open, close it if (pConnect != NULL) pConnect->Close(); delete pConnect; return;}
CFtpFileFind例子
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。