AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Zip-Dateien beschädigt

Ein Thema von Patrick · begonnen am 1. Aug 2005 · letzter Beitrag vom 1. Aug 2005
 
Patrick

Registriert seit: 15. Sep 2003
184 Beiträge
 
Delphi 2010 Professional
 
#1

Zip-Dateien beschädigt

  Alt 1. Aug 2005, 11:08
Hallo, ich hätte da mal wieder ein Problem.

Also ich zippe und unzippe mit folgender zusammengebastelter Unit Dateien:
Delphi-Quellcode:
unit compress;

interface
uses ZLib, Windows, SysUtils, Variants, Classes, Graphics, Controls, Dialogs;

  procedure CompressFiles(Files : TStrings; const Filename : String);
  procedure DecompressFiles(const infile : TMemoryStream);

implementation

procedure CompressFiles(Files : TStrings; const Filename : String);
var
  infile, outfile, tmpFile : TFileStream;
  compr : TCompressionStream;
  i,l : Integer;
  s : String;

begin
  if Files.Count > 0 then
  begin
    outFile := TFileStream.Create(Filename,fmCreate);
    try
      { the number of files } 
      l := Files.Count;
      outfile.Write(l,SizeOf(l));
      for i := 0 to Files.Count-1 do
      begin
        infile := TFileStream.Create(Files[i],fmOpenRead);
        try
          { the original filename } 
          s := ExtractFilename(Files[i]);
          l := Length(s);
          outfile.Write(l,SizeOf(l));
          outfile.Write(s[1],l);
          { the original filesize } 
          l := infile.Size;
          outfile.Write(l,SizeOf(l));
          { compress and store the file temporary} 
          tmpFile := TFileStream.Create('tmp',fmCreate);
          compr := TCompressionStream.Create(clMax,tmpfile);
          try
            compr.CopyFrom(infile,l);
          finally
            compr.Free;
            tmpFile.Free;
          end;
          { append the compressed file to the destination file } 
          tmpFile := TFileStream.Create('tmp',fmOpenRead);
          try
            outfile.CopyFrom(tmpFile,0);
          finally
            tmpFile.Free;
          end;
        finally
          infile.Free;
        end;
      end;
    finally
      outfile.Free;
    end;
    DeleteFile('tmp');
  end;
end;

procedure DecompressFiles(const infile : TMemoryStream);
var
  dest,s : String;
  decompr : TDecompressionStream;
  outfile : TFilestream;
  i,l,c : Integer;
begin
  // IncludeTrailingPathDelimiter (D6/D7 only)
  //dest := IncludeTrailingPathDelimiter(DestDirectory);

  infile.Position:=0;
  try
    { number of files } 
    infile.Read(c,SizeOf(c));
    for i := 1 to c do
    begin
      { read filename } 
      infile.Read(l,SizeOf(l));
      SetLength(s,l);
      infile.Read(s[1],l);
      { read filesize } 
      infile.Read(l,SizeOf(l));
      { decompress the files and store it } 
      s := dest+s; //include the path
      outfile := TFileStream.Create(s,fmCreate);
      decompr := TDecompressionStream.Create(infile);
      try
        outfile.CopyFrom(decompr,l);
      finally
        outfile.Free;
        decompr.Free;
      end;
    end;
  finally
 
  end;
end;

end.
Jetzt habe ich aber das Problem, dass ich die damit erzeugten Zip-Dateien nicht mit dem in Windows XP implementierten Zipper öffnen kann, da kommt immer die hübsche Fehlermeldung, dass diese beschädigt seien...
Wie muss ich meine Prozeduren ändern, dass ich sie auch mit Windows öffnen kann?
Genieße jede Minute deines Lebens, denn sie wird nicht wieder kommen.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:35 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz