Registriert seit: 3. Jul 2008
Ort: Hamburg
132 Beiträge
Delphi 10.3 Rio
|
Re: Mehrere Dateien in eine ZIP-Datei
22. Okt 2009, 15:34
So jetzt hab ich die Prozedur gefunden:
Delphi-Quellcode:
{-------------------------------------------------------------------}
procedure FileToStream( const FileName: String; Stream: TStream);
var
a : Array[0..255] of Char;
c : Cardinal;
fs: TFileStream;
begin
c := Length(ExtractFileName(FileName));
StrPCopy(@a, ExtractFileName(FileName));
Stream. Write(c, 4);
Stream. Write(a, c);
fs := TFileStream.Create(FileName, fmOpenRead);
c := fs.Size;
Stream. Write(c, 4);
Stream.CopyFrom(fs, 0);
fs.Free;
end;
{-------------------------------------------------------------------}
procedure StreamToFile(Stream: TStream);
var
a : Array[0..255] of Char;
c : Cardinal;
fs: TFileStream;
begin
FillChar(a, 255, 0);
Stream. Read(c, 4);
Stream. Read(a, c);
Stream. Read(c, 4);
fs := TFileStream.Create(a, fmCreate);
fs.CopyFrom(Stream, c);
fs.Free;
end;
{-------------------------------------------------------------------}
// Packen
var
ms: TMemoryStream;
begin
ms := TMemoryStream.Create;
FileToStream(' .\Export-Artikel.txt', ms);
FileToStream(' .\Export-Verkauf.txt', ms);
FileToStream(' .\Export-Kunden.txt', ms);
FileToStream(' .\Einstellungen.ini', ms);
ms.SaveToFile(' .\DB.auddb');
ms.Free;
end;
// Entpacken
var
ms: TMemoryStream;
begin
ms := TMemoryStream.Create;
ms.LoadFromFile(' .\DB.auddb');
StreamToFile(ms);
StreamToFile(ms);
StreamToFile(ms);
StreamToFile(ms);
ms.Free;
end;
|
|
Zitat
|