Autor Beitrag
bigmasterdenis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 48



BeitragVerfasst: Mi 15.08.07 21:01 
Hallo Leute!

Ich packe mit Hilfe der ZLib-Unit von Delphi einige Dateien in ein zip-Archiv. Fürs packen benutze ich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure Compress(InputFileName, OutputFileName: string);
var InputStream, OutputStream: TFileStream;
  CompressionStream: ZLib.TCompressionStream;
begin
  InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
  try
    OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
    try
      CompressionStream:=TCompressionStream.Create(clMax, OutputStream);
      try
        CompressionStream.CopyFrom(InputStream, InputStream.Size);
      finally
        CompressionStream.Free;
      end;
    finally
      OutputStream.Free;
    end;
  finally
    InputStream.Free;
  end;
end;


Die Dateien werden auch entsprechend komprimiert, als hätte ich es mit WinZip/WinRar gemacht. Versuche ich nun mein erstelles zip-File mit WinZip/WinRar zu öffnen kommt eine Fehlermeldung ala ungültiges Archiv. Jemand eine Idee woran das liegen könnte und was man machen kann?

Danke für eure Hilfe!

Gruss
Denis

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 15.08.07 21:09 
Du musst WinZip auch sagen, worum es sich bei deiner Datei handelt usw. Dafür benötigst Du einen Datei-Header, der in deinem Beispiel fehlt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
IceBube
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 231



BeitragVerfasst: Mi 15.08.07 21:44 
hm...

wieso nimmst du nicht gleich einen Zip Komponenten her und packst die Dateien mit Hilfe von diesem Komponenten....

Wieso machst du dir es schwer, wenns auch leichter geht ^?

lg
bigmasterdenis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 48



BeitragVerfasst: Mi 15.08.07 22:33 
danke für die schnellen Antworten :-)

@BenBE
hhm... wie sieht denn so ein Datei-Header aus? Gibts irgendwo ein Beispiel dazu?

@IceBube
mit Zip Komponenten meinst bestimmt sowas wit ZipMaster? Da muss man sich auf irgendwelche externen DLL's beziehen und so. Mir wäre es lieber wenn alles nötige nachher in meiner .exe steckt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 15.08.07 22:38 
Infos zu vielen Dateiformaten findest Du auf wotsit.org ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
bigmasterdenis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 48



BeitragVerfasst: Do 16.08.07 16:53 
Auf wotsit.org steht eine Menge zum zip-Format... aber ich habe trotzdem nicht die geringste Ahnung wie ich einen Datei Header mit Delphi erstellen kann. :(
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 16.08.07 19:39 
Es gibt genug "Native Delphi" Zip-Komponenten/-Klassen.

Einfach mal suchen, spontan fällt mir KAZip ein, es gibt auch noch einige andere.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
bigmasterdenis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 48



BeitragVerfasst: Fr 17.08.07 11:28 
:) :) :)

Danke Martok!!!

KAZip ist genau was ich gesucht hatte. Funktioniert super!