次の方法で共有


CFtpFileFind クラス

更新 : 2007 年 11 月

FTP サーバーのインターネット ファイル検索を支援します。

class CFtpFileFind : public CFileFind

解説

CFtpFileFind には、検索の開始、ファイルの検索、および URL またはファイルに関するその他の情報を返すメンバ関数があります。

インターネット ファイルとローカル ファイルを検索するためにデザインされた MFC のクラスには、ほかに CGopherFileFindCFileFind があります。CFtpFileFind と組み合わせて使うと、これらのクラスは、サーバー プロトコル、ファイル種別、またはローカル コンピュータあるいはリモート サーバーという場所に関係のない、シームレスなファイル検索機能を、クライアントに提供します。HTTP では検索に必要なファイルの直接操作をサポートしないため、HTTP サーバーを検索する MFC クラスは存在しません。

CFtpFileFind などの WinInet クラスの使い方の詳細については、「Win32 インターネット拡張機能 (WinInet)」を参照してください。

使用例

次のコードは、FTP サーバーの現在のディレクトリにあるすべてのファイルを列挙する方法を示しています。

// 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("My FTP Session"));

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();
      _tprintf_s(_T("%s\n"), (LPCTSTR)finder.GetFileURL());
   }
}
catch (CInternetException* pEx)
{
   TCHAR sz[1024];
   pEx->GetErrorMessage(sz, 1024);
   _tprintf_s(_T("ERROR!  %s\n"), sz);
   pEx->Delete();
}

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

必要条件

ヘッダー : afxinet.h

参照

参照

CFileFind クラス

階層図

CGopherFileFind クラス

CInternetFile クラス

CGopherFile クラス

CHttpFile クラス

その他の技術情報

CFtpFileFind のメンバ