Вниз
Скачать: CL | DM;

Как перебрать все файлы с FTP ?   Найти похожие ветки 

← →
user   (2008-08-01 16:12) [0]

Подскажите, как перебрать  файлы в цикле с ftp..
IDFTP.Get ("назв. файла на FTP") ,"путь на локальной машине.txt");


← →
Rouse_ ©   (2008-08-01 16:40) [1]

эммнь... так пойдет?

uses
 WinInet;

procedure TForm27.Button1Click(Sender: TObject);

 procedure FindFTPFiles(FConnect: HINTERNET; Dir: String);
 var
   hFileConnection: HINTERNET;
   FindData: TWin32FindData;
   SubDirs: TStringList;
   I: Integer;
 begin
   SubDirs := TStringList.Create;
   try
     FtpSetCurrentDirectory(FConnect, PChar(Dir));
     hFileConnection := FtpFindFirstFile(FConnect, pChar("*.*"), FindData,
       INTERNET_FLAG_NEED_FILE , 0);
     if hFileConnection <> nil then
     try
       ZeroMemory(@FindData, SizeOf(TWin32FindData));

       while InternetFindNextFile(hFileConnection, @FindData) do
       begin
         if
           (StrPas(FindData.cFileName) = ".") or
           (StrPas(FindData.cFileName) = "..") then
           Continue;

         if FindData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY then
         begin
           SubDirs.Add(Dir + String(FindData.cFileName) + "/");
           Memo1.Lines.Add(Dir + String(FindData.cFileName) + "/");
         end
         else
           Memo1.Lines.Add(Dir + String(FindData.cFileName));

         Application.ProcessMessages;
         //if Memo1.Lines.Count > 100 then Break;
       end;

     finally
       InternetCloseHandle(hFileConnection);
     end;

     for I := 0 to SubDirs.Count - 1 do
       FindFTPFiles(FConnect, SubDirs.Strings[I]);

   finally
     SubDirs.Free;
   end;
 end;

var
 FSession, FConnect: HINTERNET;
 FHost: String;

begin
 FHost := "ftp.synclub.ru";
 FSession := InternetOpen("", INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
 if not Assigned(FSession) then Exit;
 try
   FConnect := InternetConnect(FSession, PChar(FHost),
     INTERNET_DEFAULT_FTP_PORT, PChar("synclub"),
     PChar("synclub"), INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
   if not Assigned(FConnect) then Exit;
   try
     FindFTPFiles(FConnect, "/jazz/3rd Force/");
     Memo1.Lines.Add("=====================================");
     Memo1.Lines.Add("All done");
   finally
     InternetCloseHandle(FConnect);
   end;
 finally
   InternetCloseHandle(FSession);
 end;
end;


← →
Dennis I. Komarov ©   (2008-08-04 14:26) [2]

> [0] user   (01.08.08 16:12)

List...


← →
Dennis I. Komarov ©   (2008-08-05 10:00) [3]

> [1] Rouse_ ©   (01.08.08 16:40)

А информация из
> hFileConnection := FtpFindFirstFile(FConnect, pChar("*.*")
> , FindData,
>       INTERNET_FLAG_NEED_FILE , 0);

Куда пропала?


← →
user   (2008-08-05 14:25) [4]

не совсем поняла код....пишу так ...
но теперь выходит другая ошибка :
begin
sl:=TStringList.Create;
try
with IdFTP do
begin
  Host := "10.1.6.23";
  Password := "XXX";
  Username := "CR";
  Connect;
  ChangeDir ("CSVED");//("cdr");

   List(sl, " ",False);  
  for i:=0 to idFTP.DirectoryListing.Count-1 do
   begin
здесь выходит  Ошибка: Unknown FTP Listing format


← →
Anatoly Podgoretsky ©   (2008-08-05 14:43) [5]

Количество форматов более 50, а Инди поддерживает только несколько.


← →
user   (2008-08-05 15:37) [6]

спасибо всем за ответы, все получилось!


← →
user   (2008-08-05 15:37) [7]

спасибо всем за ответы, все получилось!



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.47 MB
Время: 0.044 c
2-1269008966
allrussia
2010-03-19 17:29
2010.08.27
Как отловить нажатие кнопки во время появления PopupMenu


2-1269172946
Первокурсница
2010-03-21 15:02
2010.08.27
Программа вылетает (delphi 7), свойство кнопки Enabled или Visibl


8-1204201324
ERT
2008-02-28 15:22
2010.08.27
PrintScreen


11-1219772870
Артем
2008-08-26 21:47
2010.08.27
Ticqclient на KOL е


11-1216300266
Ruzzz
2008-07-17 17:11
2010.08.27
Есть что-то подобное TCriticalSection в KOL




   Наверх