Delphi中压缩文件的最好方式是使用ZipTV控件。其样例代码如下: procedure TForm1.Button1Click(Sender: TObject); var FileCompressed,I: Integer; FileName:String; begin if SaveDialog1.Execute then begin Zip1.ArchiveFile := SaveDialog1.FileName; Zip1.DateAttribute := daFileDate; // default value Zip1.StoredDirNames := sdRelative; // default value Zip1.CompressMethod := cmDeflate; // default value
Zip1.FileSpec.Clear; for I := 0 to ListBox1.Items.Count - 1 do // Iterate begin Zip1.FileSpec.Add(ListBox1.Items[i]); end; // for
FileCompressed := Zip1.Compress; end; end;
|
请发表评论