用vclzip 吧 很好用
GetZipFileDlg.Filename := '';
if GetZipFileDlg.Execute then
begin
fn := GetZipFileDlg.FileName;
if pos(UpperCase(exepath), UpperCase(fn)) > 0 then
begin
ShowMessage('请选择一个不在' + exepath + '下的文件进行备份!');
exit;
end;
if UpperCase(ExtractFileExt(fn)) <> '.ZIP' then
ChangeFileExt(fn, '.zip');
Zipper.ClearZip;
Zipper.FilesList.Clear;
Zipper.ZipName := fn;
if FileExists(fn) then
DeleteFile(fn);
Zipper.RootDir := exepath;
for Arow := 1 to RzStringGrid1.RowCount - 1 do
begin
if RzStringGrid1.Cells[1, arow] <> '' then
begin
idx := Zipper.FilesList.Add(exepath + RzStringGrid1.Cells[0, arow] + RzStringGrid1.Cells[1, arow]);
// Zipper.Pathname[idx] := RzStringGrid1.Cells[0, arow];
end;
end;
CurrentFileLabel.Caption := '';
Gauge1.Progress := 0;
Gauge2.Progress := 0;
RzPanel1.Visible := true;
self.Update;
Zipper.ZipComment := '鉴定备份文件(' + FormatDateTime('YYYY-MM-DD hh:nn:ss', now) + ')';
DM.ADOConn.Close;
Zipper.Zip;
CurrentFileLabel.Caption := '';
Gauge1.Progress := 0;
Gauge2.Progress := 0;
RzPanel1.Visible := false;
ShowMessage('已经备份到 ' + fn + ' !');
DM.ADOConn.open;
end;