Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Сети > Получить список директорий FTP


Автор: maestro2k 18.6.2006, 15:31
Как получить список директорий FTP сервера пользууясь WinInet? 

Автор: Mechanic 18.6.2006, 20:11
Цитата(MSDN said)

Directory enumeration is performed by using the FtpFindFirstFile and InternetFindNextFile functions. FtpFindFirstFile uses the session handle created by InternetConnect to find the first file that matches the given search criteria and returns a handle to continue the directory enumeration. InternetFindNextFile uses the handle returned by FtpFindFirstFile to return the next file that matches the original search criteria. The application should continue to call InternetFindNextFile until there are no more files left in the directory.


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/ftp_sessions.asp

Если нужно полное дерево директорий, то как и на локальном диске - лучше всего рекурсивной функой.
FtpFindFirstFile, InternetFindNextFile по-ходу не шибко отличаются от FindFirstFile, FindNextFile. 

Автор: maestro2k 20.6.2006, 20:26
Самое главное чтоб была инфа о директориях (т.е. доступна для зписи или для чтения т.п.)
Дайте пример плиз. 

Автор: maestro2k 27.8.2006, 16:50
Код

var
 FtpHandle,InetHandle, hFind: HInternet;
 s:WIN32_FIND_DATA;

procedure TForm1.Button2Click(Sender: TObject);
begin
   InetHandle := InternetOpen(PChar('FTP'), 0, nil, nil, 0);
    FtpHandle := InternetConnect(InetHandle, PChar('10.10.11.8'), 21, PChar('Anonymous'),
        PChar('qwerty.ru'), INTERNET_SERVICE_FTP, 0, 255);
   if not Assigned(FtpHandle) then
      InternetCloseHandle(InetHandle)
   else

        try
        hFind:= FtpFindFirstFile(FtpHandle, PChar('*.*'), s, FTP_TRANSFER_TYPE_BINARY, 255);
        except
        exit;
     end;
     ListBox1.Items.Add(s.cFileName + ' | ' + intToStr(s.dwFileAttributes));
     while InternetFindNextFile(hFind, @s) do
     begin
       ListBox1.Items.Add(s.cFileName + ' | ' + intToStr(s.dwFileAttributes))
     end;
  InternetCloseHandle(InetHandle);
end;


Как мне узнать возможна ли запись файла в некую директорию??? s.dwFileAttributes - возвращает помоему не то значение

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)