CFtpFileFind



  • hallo,
    ich möchte jedes Verzeichniss eines ftpservers durchsuchen. ich habe mir gedacht ich könnte dies mit einer rekursiven Funktion von CFtpFileFind machen. so wie es im beispiel von cfindfile gemacht wird. aber es funktioniert bei mir nicht rekursiv.

    ________________________________________________________________

    BOOL ftp_test::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("MyProgram/1.0"));
    
       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("localhost"));
    
          // use a file find object to enumerate files
    
    		ftp_find("");
    
       }
       catch (CInternetException* pEx)
       {
          TCHAR sz[1024];
          pEx->GetErrorMessage(sz, 1024);
          m_MYListB.AddString("ERROR!");
          pEx->Delete();
       }
    
       // if the connection is open, close it
       if (pConnect != NULL)
          pConnect->Close();
       delete pConnect;
    
       return true;
    }
    
    BOOL ftp_testDlg::ftp_find(LPCTSTR pstr){
    
    	pConnect->SetCurrentDirectory(pstr);
    	CString str;
    	pConnect->GetCurrentDirectory(str); 
    	MessageBox(str);
    	CFtpFileFind finder2(pConnect);
    	//CString strWildcard(pstr);
    	//strWildcard += _T("/");
    
         BOOL bWorking = finder2.FindFile(_T(NULL));
    
          while (bWorking)
          {
             bWorking = finder2.FindNextFile();
    
    	 if (finder2.IsDirectory()) 
          {
    		 str = finder2.GetFilePath();
    		 ftp_find(str);
    		 }
    	 else{
             m_MYListB.AddString((LPCTSTR) finder2.GetFileURL());
    		}
          }
    	finder2.Close();
    
    	return true;
    }
    


  • http://www.vinzenz.freesites.ws/ftp_protokoll.gif
    wie mann hier sieht wechselt mein programm den pfadt, aber macht kein LIST mehr.


Anmelden zum Antworten