Einzelnen Beitrag anzeigen

Mr Whoopee

Registriert seit: 28. Jun 2004
73 Beiträge
 
#15

Re: In Stream mehrere Dateien laden?

  Alt 24. Sep 2004, 15:22
Delphi-Quellcode:
Unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    IdHTTP1: TIdHTTP;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  stream: TFileStream;
  stream1, stream2: TMemoryStream;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
try
stream := TFileStream.Create('c:\temp', fmCreate);
IdHTTP1.Get('http://home.arcor.de/delphi_checker/testdl/1.gif', stream);
finally
stream.Free;
end;
   try
   stream1:=TMemoryStream.Create;
   stream2:=TMemoryStream.Create;
   stream1.LoadFromFile('c:\temp');
   stream2.LoadFromFile('c:\final');
   stream1.Position:=stream1.Size;
   stream1.CopyFrom(stream2,0);
   stream1.SaveToFile('c:\final');
   finally
   stream2.Free;
   stream1.Free;
   end;
try
stream := TFileStream.Create('c:\temp', fmCreate);
IdHTTP1.Get('http://home.arcor.de/delphi_checker/testdl/2.gif', stream);
finally
stream.Free;
end;
   try
   stream1:=TMemoryStream.Create;
   stream2:=TMemoryStream.Create;
   stream1.LoadFromFile('c:\temp');
   stream2.LoadFromFile('c:\final');
   stream1.Position:=stream1.Size;
   stream1.CopyFrom(stream2,0);
   stream1.SaveToFile('c:\final');
   finally
   stream2.Free;
   stream1.Free;
   end;
try
stream := TFileStream.Create('c:\temp', fmCreate);
IdHTTP1.Get('http://home.arcor.de/delphi_checker/testdl/3.gif', stream);
finally
stream.Free;
end;
   try
   stream1:=TMemoryStream.Create;
   stream2:=TMemoryStream.Create;
   stream1.LoadFromFile('c:\temp');
   stream2.LoadFromFile('c:\final');
   stream1.Position:=stream1.Size;
   stream1.CopyFrom(stream2,0);
   stream1.SaveToFile('c:\final');
   finally
   stream2.Free;
   stream1.Free;
   end;
try
stream := TFileStream.Create('c:\temp', fmCreate);
IdHTTP1.Get('http://home.arcor.de/delphi_checker/testdl/4.gif', stream);
finally
stream.Free;
end;
   try
   stream1:=TMemoryStream.Create;
   stream2:=TMemoryStream.Create;
   stream1.LoadFromFile('c:\temp');
   stream2.LoadFromFile('c:\final');
   stream1.Position:=stream1.Size;
   stream1.CopyFrom(stream2,0);
   stream1.SaveToFile('c:\final');
   finally
   stream2.Free;
   stream1.Free;
   end;
try
stream := TFileStream.Create('c:\temp', fmCreate);
IdHTTP1.Get('http://home.arcor.de/delphi_checker/testdl/5.gif', stream);
finally
stream.Free;
end;
   try
   stream1:=TMemoryStream.Create;
   stream2:=TMemoryStream.Create;
   stream1.LoadFromFile('c:\temp');
   stream2.LoadFromFile('c:\final');
   stream1.Position:=stream1.Size;
   stream1.CopyFrom(stream2,0);
   stream1.SaveToFile('c:\final');
   finally
   stream2.Free;
   stream1.Free;
   end;
try
stream := TFileStream.Create('c:\temp', fmCreate);
IdHTTP1.Get('http://home.arcor.de/delphi_checker/testdl/6.gif', stream);
finally
stream.Free;
end;
   try
   stream1:=TMemoryStream.Create;
   stream2:=TMemoryStream.Create;
   stream1.LoadFromFile('c:\temp');
   stream2.LoadFromFile('c:\final');
   stream1.Position:=stream1.Size;
   stream1.CopyFrom(stream2,0);
   stream1.SaveToFile('c:\final');
   finally
   stream2.Free;
   stream1.Free;
   end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
stream := TFileStream.Create('c:\final', fmCreate);
stream.Free;
end;

end.
So sieht es aues - ist noch umständlich gemacht - ich weiß - war zu faul - wollte es geh nur testen...
rauskommen MÜSSTE eigentlich ne exe - als auf C:\ die "Final" Datei in "Final.exe" umbenennen - aber dann geht die exe nicht.
Hochgeladen habe ich es im Binary Mode.
  Mit Zitat antworten Zitat