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: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198:
| unit Unit4;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, FileCtrl, StdCtrls, Gauges, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, IdHTTP, ExtCtrls, Menus, mmSystem ,shellapi, IdException, IdAntiFreezeBase, IdAntiFreeze;
type FTPCOPY = class(TThread) idftp2:Tidftp; idhttp2:Tidhttp; Procedure schicken; Procedure holen;
private
protected procedure Execute; override;
public
a,x,z:integer; art,host,username,password,loeschen:string; uploadquelle,uploadziel:tstringlist; downloaddatei,downloadpfad,downloadquelle:tstringlist; quelle,ziel,aktuelledatei:string;
end;
implementation uses unit2,unit1;
procedure FTPCOPY.Execute; var hostname,quelle,ziel:string; var host:tstringlist; uploadquelle,uploadpfad,uploaddatei:tstringlist; downloadquelle,downloadpfad,downloaddatei:tstringlist; begin host:=tstringlist.create; host.LoadFromFile('c:\databridge\databridge.txt');
idftp2:=Tidftp.Create(nil); idftp2.Host:=host.Text; form2.memo2.text:=inttostr(idftp2.BoundPort); form2.Memo2.Text:=host.text; host.Free; unit2.form2.Memo2.Show; idftp2.Username:=form2.IdFTP1.Username; idftp2.Password:=form2.IdFTP1.Password;
idftp2.Connect; if unit2.form2.art='UP' then begin schicken; end; if unit2.Form2.art='down'then begin holen; end;
end;
procedure FTPCOPY.schicken ; var a,zaehler:integer; uploadquelle,uploadpfad,uploaddatei,slist:tstringlist; f:file of Byte; size:longint; begin uploadquelle:=tstringlist.create; uploadpfad:=tstringlist.create; uploaddatei:=tstringlist.create; uploadquelle.clear; uploaddatei.clear; uploadpfad.clear; if fileexists('c:\databridge\upload\uploadquelle.txt') then uploadquelle.LoadFromFile('c:\databridge\upload\uploadquelle.txt'); if fileexists('c:\databridge\upload\uploadpfad.txt') then uploadpfad.LoadFromFile('c:\databridge\upload\uploadpfad.txt'); if fileexists('c:\databridge\upload\uploaddatei.txt') then uploaddatei.LoadFromFile('c:\databridge\upload\uploaddatei.txt'); form2.Label13.Caption:=inttostr(uploadquelle.Count); SList := TStringList.Create; unit2.Form2.FileListBox4.Items:=uploaddatei; for a := 0 to uploaddatei.count -1 do begin try
idftp2.changedir(uploadpfad[a]); if idftp2.size(uploadpfad[a]+uploaddatei[a])>1 then idftp2.Delete(uploadpfad[a]+uploaddatei[a]); idftp2.put(uploadquelle[a] , (uploadpfad[a]+uploaddatei[a]), true); unit2.Form2.Memo2.Text:=('Schreibe Aktuell: '+uploadquelle[a]+' nach '+uploadpfad[a]+uploaddatei[a]); unit2.Form2.Label13.caption:=inttostr(uploaddatei.count -a);
except on E:EIdSocketError do
begin idftp2.Connect;
end; end; unit2.form2.label17.caption:='Upload läuft'; IdFTP2.List(Slist,'*.*',false); unit2.Form2.filelistbox2.Items:=SList; end;
deletefile('c:\databridge\upload\uploadquelle.txt'); deletefile('c:\databridge\upload\uploadpfad.txt'); deletefile('c:\databridge\upload\uploaddatei.txt'); unit2.form2.label17.caption:='Upload Beendet';
unit2.Form2.FileListBox4.Clear; unit2.Form2.Label13.caption:='0' end;
procedure FTPCOPY.holen; var a,zaehler:integer; downloadquelle,downloadpfad,downloaddatei,slist:tstringlist; size:longint; begin downloadquelle:=tstringlist.create; downloadpfad:=tstringlist.create; downloaddatei:=tstringlist.create; if fileexists('c:\databridge\download\downloadquelle.txt') then downloadquelle.LoadFromFile('c:\databridge\download\downloadquelle.txt'); if fileexists('c:\databridge\download\downloadpfad.txt') then downloadpfad.LoadFromFile('c:\databridge\download\downloadpfad.txt'); if fileexists('c:\databridge\download\downloaddatei.txt') then downloaddatei.LoadFromFile('c:\databridge\download\downloaddatei.txt'); form2.Label13.Caption:=inttostr(downloadquelle.Count);
unit2.Form2.Label17.Caption:='Download läuft'; SList := TStringList.Create; unit2.Form2.FileListBox4.Items:=downloaddatei;
for a := 0 to downloaddatei.count -1 do begin try aktuelledatei:=downloadpfad[a]; unit2.Form2.Memo2.Text:=('Schreibe Aktuell: '+downloadquelle[a]+downloaddatei[a]+' nach '+downloadpfad[a]); unit2.form2.gauge1.MaxValue:=idftp2.size(downloadquelle[a]+downloaddatei[a]); unit2.form2.zieldatei:=(downloadpfad[a]);
idftp2.get((downloadquelle[a]+downloaddatei[a]) , downloadpfad[a], true);
unit2.Form2.Label12.caption:=inttostr(downloaddatei.count -a) except on E:EIdSocketError do
begin idftp2.Connect; end; end;
unit2.Form2.FileListBox1.update; end; deletefile('c:\databridge\download\downloadquelle.txt'); deletefile('c:\databridge\download\downloadpfad.txt'); deletefile('c:\databridge\download\downloaddatei.txt'); unit2.form2.label17.caption:='Download Beendet';
unit2.Form2.filelistbox4.Clear; unit2.Form2.Label12.caption:='0' end;
end. |