Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

закачка на FTP файлов в потоке [D7, Win2k]


integerr ©   (2004-12-27 19:03:00) 

закачиваю файл на FTP (IdFTP) в потоке, но когда видергнуть шнур из сетевой карти то получаєтся облом хоть и потом появитса связь. Нужно штоб програма продолжала питатса закачать пока незакачаєт все указаниє файлы, подскажите как ?


JorSand   (2005-01-01 21:45:00) [1]

Я слышал о подобном трабле с физическим разрывом коннекта. Ребята idServer правили.


Piter   (2004-12-30 21:30:00) [2]

Так в чем проблема? На какой строчке кода ошибка?


intgerr   (2004-12-30 12:09:00) [3]

ну ясно , сделал без потоков то качаєт нормально но тогда притармаживаєт , вижу ету тему можна и не поднимать так толком нечего нескажут!!!


Piter   (2004-12-29 23:28:00) [4]

ну если твой код правильный - в чем тогда проблема?

P.S.

Exception - исключение
Error - ошибка


integerr   (2004-12-29 13:52:00) [5]

вот именно ошибки нет (Excaption)


Piter   (2004-12-29 01:53:00) [6]

А что не работает в ТВОЕМ алгоритме, на какой строчке ошибка?


integerr   (2004-12-28 19:58:00) [7]

што никто не имел подобной  проблеми


integerr   (2004-12-28 13:48:00) [8]

проблема в том єсли связь упала и потом поднялась загрузка невозобновляєтса!!! может у кавота єсь примерчик такова алгоритма


Piter   (2004-12-28 11:33:00) [9]

Лично мне разбираться в чужом коде влом.

Я так и не понял - в чем конкретно проблема?


integerr   (2004-12-28 10:39:00) [10]

вот мой код
procedure TForm1.start;
var
sr:TSearchRec;
i:word;
FtpUploat:TThread;
r:integer;
begin
ListBox2.Clear;
ListBox1.Clear;
      MadeList;
      if FindFirst(Label1.Caption+'\*.*',faArchive,sr)=0 then
         repeat
         if not find(sr.Name,sr.Size) then ListBox1.Items.Add(sr.Name);
          until FindNext(sr) <> 0;
         FindClose(sr);
         if ListBox1.Count > 0  then
           begin
             mage_log;
             SpeedButton1.Enabled:=true;
             {while ListBox1.Items.Count <> -1 do
               begin
               if not ftp.Connected then break;
               if download(ListBox1.Items[0]) then ListBox1.Items.Delete(0);
               end;  }
             for i:=ListBox1.Items.Count-1 downto 0 do
              begin
             endPtok:=0;
             FtpUploat:=PLoad.create(false,host.Text,port.Text,username.Text,pass.Text,Label1.Caption+'\'+ListBox1.Items[i],ListBox1. Items[i],path.Text);
             FtpUploat.FreeOnTerminate:=true;
             while endPtok=0 do pause(1);
             if endPtok=3 then exit;
             if endPtok =2 then ListBox1.Items.Delete(i);
             end;
           end;
    // end
     // else
      ftp.Abort;
      ftp.Quit;
      ftp.Disconnect;
      if  ListBox1.Items.Count<0 then Application.Terminate else Exception.Create('');
      //Close;
end;

Function TForm1.find(name: string; siz: integer):boolean;
var
i:word;
faund:boolean;
begin
  if ftp.DirectoryListing.Count > 0 then
     begin
       faund:=false;
       for I:=ftp.DirectoryListing.Count-1 downto 0 do
           if (name=ftp.DirectoryListing[i].FileName) and (siz=ftp.DirectoryListing[i].Size) then
               faund:=true;
     end else faund:=false;
Result:=faund;
end;

unit potok;

interface

uses
 Classes,FTPsend,idftp,IdLogEvent,IdFTPCommon, IdFTPList,SysUtils,unit1;

type
 PLoad = class(TThread)

 Phost,Pport,Puser,Ppass,PFullname,Pname,PftpDir:string;

   private
   { Private declarations }
 protected
   S:string;
   procedure Execute; override;

 public
 constructor create(CreateSuspennded:boolean;Lhost,Lport,Luser,Lpass,LFullname,Lname,LftpDir:string);
   end;

implementation

uses IdTCPConnection,blcksock;

constructor PLoad.create(CreateSuspennded: boolean; Lhost, Lport, Luser,
 Lpass, LFullname, Lname,LftpDir: string);
begin
inherited create(CreateSuspennded);
Phost:=Lhost;
Pport:=Lport;
Puser:=Luser;
Ppass:=Lpass;
PFullname:=LFullname;
Pname:=Lname;
PftpDir:=LftpDir;
///PIdLogEvent:=LIdLogEvent;
end;

procedure PLoad.Execute;
var
res:integer;
begin
 { Place thread code here }
res:=1;
with TFTPSend.Create do  try
   Username:=Puser;
   Password:=Ppass;
   TargetHost:=Phost;
   TargetPort:=Pport;
   if not Login then exit;
//delete file, before sending
FTPCommand('DELE ' + PftpDir+'/'+Pname);
DirectFileName := PFullname;
DirectFile:=true;
if StoreFile(PftpDir+'/'+Pname,false)=true then res:=2;
 Logout;
Except res:=3  end;
Form1.endPtok:=res;
//Terminate;
Free;
end;
end.


Piter   (2004-12-27 22:01:00) [11]

повторить процесс посылки, пока не удастся полностью передать файл.


Наверх

Титульная страница Поиск, карта сайта Написать письмо