Autor Beitrag
kalle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20

Alles mögliche
D7 ?
BeitragVerfasst: Sa 11.10.08 23:58 
Hi an alle
Also hab jetzt meinen FTPclient fast fertig.
Dieser soll meinen Leuten(Familie)auf einfache weise erlauben Fotos auf meinem Server ins Fotoalbum oder
sonst wo hinzu bringen.
Hab das ganz einfach aufgebaut
Verbinden.(IP vom server Holen und login)
Jetzt wird die Fileliste vom Server auf der rechten seite angezeigt.(Vorher nicht)
Jetzt hab ich erstmal 2 fragen
1)Wie kann ich den idftp1 aus der Form2 benutzen ohne für den Thread nen neuen machen zu müssen.
2)Was kann ich gegen das connection refused machen.
Also Ohne thread läuft das Uploaden und Downloaden 100% nur das Programm hängt dann solange bis up oder download erledigt sind. Wie kann ich im thread das on work workacount einsetzen? Bei Form2 hab ich das ja visuell aus den indyclients auf die Form gezogen der thread hat aber keine Form Freue mich auf jede Hilfe
Danke im voraus
Damit das Programm nicht hängt hab ich den upload in nen thread gepackt der aufruf sieht so aus:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
procedure TForm2.Button17Click(Sender: TObject);
var
  
  s,quelle,filename,dest,fi:string;
  a,b,c,i:integer;
  slist,uploadlist:tstringlist;
  f: file of Byte;
  size: Longint;
  
  begin
  
  label13.Caption:=inttostr(filelistbox1.SelCount);

     begin
      //Filesize ermitteln -----------------------------------------------------
      AssignFile(f, filelistbox1.FileName);
     Reset(f);
     try
     size := FileSize(f);
     finally
     CloseFile(f);
     //-------------------------------------------------------------------------


     gauge1.MaxValue:=size;
     gauge1.MinValue:=0;


     end;

     

     // Upload von selected Files  --------------------------------------------------
     uploadlist :=tstringlist.Create;
      for a :=0 to filelistbox1.Count -1 do begin
      if filelistbox1.Selected[a] then uploadlist.Add(filelistbox1.items[a])
      end;
     filelistbox3.Items:=uploadlist;
     for a := 0 to filelistbox1.Count -1 do begin
     if filelistbox1.Selected[a] then begin
     quelle:=(FileListBox1.Directory+'\'+FileListBox1.Items[a]);
     filename:=FileListBox1.Items[a];
  
      //Thread starten
      FTPKopie:=FTPCOPY.create(true);
      FTPKopie.quelle:=quelle;
      FTPKopie.filename:=filename;
      FTPKopie.resume;

 { wenn ich den idftp1.put siehe unten benutze kommt der Fehler nicht!! nur im thread}

    //IdFTP1.Put(FileListBox1.Directory+'/'+FileListBox1.Items[a], FileListBox1.Items[a], true);

   
    end;
  end;
//Listbox2 Serverseite update---------------------------------------------------
 SList := TStringList.Create;
IdFTP1.List(Slist,'*.*',false);
Filelistbox2.Items:=SList;
filelistbox3.Clear;
 end;
end;



So jetzt der thread


unit Unit4;

interface

uses
  Classes, StdCtrls, idftp, Forms;

type
  FTPCOPY = class(TThread)
  idftp2:Tidftp;
  Procedure schicken;


  private


    { Private declarations }
  protected
    procedure Execute; override;

   public
   quelle,filename:string;

  end;

implementation
uses unit2,unit1;
{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure FTPCOPY.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }


{ FTPCOPY }

procedure FTPCOPY.Execute;
begin

idftp2:=Tidftp.Create(nil);
idftp2.Host:='192.168.128.119';
idftp2.Username:='mrx';
idftp2.Password:='cyclon';

idftp2.Connect;
idftp2.ChangeDir('/f:/ftp/mrx/');
//idftp2.Put(quelle,filename, true);
schicken;
idftp2.Disconnect;
end;  { Place thread code here }
//// hab das mal extra ausgelagert aber der Fehler kommt trotzdem!!!

procedure FTPCOPY.schicken ;
begin
idftp2.Put(quelle,filename, true);
end;

end.


---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Also ok ich kann idftp1 benutzen hab im thread immer die 2 durch ne 1 ersetzt es kommt aber trozdem der connection refused Fehler!!

Moderiert von user profile iconNarses: Delphi-Tag repariert
kalle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20

Alles mögliche
D7 ?
BeitragVerfasst: Sa 06.12.08 23:47 
Titel: Hallo an alle also ich habs gefunden das Problem
Es hatte nix mit dem Thread zu tun .sondern mit dem Hauptprogramm
Da war der Fehler jetzt hab ich über 700Fotos mit 803 mb up und downgeladen alles
roger
nur Wenn ich von einem Externen PC downloade läd er zwar alles herunter aber beendet den download nicht!
hm hat einer ne ahnung?