如何做到在程序中解压缩、压缩后缀名为zip的压缩文件,急!!!

csdn_tw 2006-10-23 05:41:06
我不想用什么命令行程序,可以考虑用控件或dll什么的,大家帮帮忙忙啊,分不够可以再加
...全文
177 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
TonyShen277 2006-10-25
  • 打赏
  • 举报
回复
function UnZipFile(DesPathName, ZipFileName: string; OverWrite: Boolean;
IsDir: Boolean; sPwd: string): Boolean;
begin
Result := False;
if IsDir and (not DirectoryExists(DesPathName)) then
MkDir(DesPathName);
if IOResult <> 0 then Exit;
if not FileExists(ZipFileName) then Exit;
with TVCLUnZip.Create(nil) do
try
try
Password := sPwd;
DoProcessMessages := True;
ZipName := ZipFileName;
ReadZip;
if Count = 0 then Abort; // 没有文件的情况 zmj
DestDir := DesPathName;
DoAll := True;
RecreateDirs := True;
if OverWrite then
OverwriteMode := ifNewer
else
OverwriteMode := Never;
UnZip;
Result := True;
except
Result := false;
end;
finally
Free;
end;
end;
TonyShen277 2006-10-25
  • 打赏
  • 举报
回复
VCLZip控件
function ZipFile(SrcPathName, ZipFileName: string; OverWrite: Boolean;
IsDir: Boolean; sPwd: string): Boolean;
var
VCLZip: TVCLZip;
ZFileList: TStringList;
begin
Result := False;
ZFileList := TStringList.Create;
VCLZip := TVCLZip.Create(nil);
try
if IsDir and (not DirectoryExists(SrcPathName)) then
MkDir(SrcPathName);
ZFileList.Text := SrcPathName;
with VCLZip do
try
Password := sPwd;
DoProcessMessages := True;
DoAll := True;
if OverWrite then
begin
OverwriteMode := Always;
ZipAction := zaReplace;
end else begin
OverwriteMode := Never;
ZipAction := zaUpdate;
end;
FlushFilesOnClose := True;
if IsDir then
RootDir := SrcPathName
else
RootDir := ExtractFilePath(SrcPathName);
FilesList.Clear;
if IsDir then
FilesList.Add('*.*')
else
FilesList.Assign(ZFileList);
RelativePaths := True;
ZipName := ZipFileName;
Zip;
Result := True;
except
Result := False;
end;
finally
VCLZip.Free;
ZFileList.Free;
end;
end;
老之 2006-10-23
  • 打赏
  • 举报
回复
VCLZip既然是VCL就肯定有BCB版的,去www.ccrun.com找找
csdn_tw 2006-10-23
  • 打赏
  • 举报
回复
我用的是BCB,有BCB的吗?
老之 2006-10-23
  • 打赏
  • 举报
回复
要功能强大一点支持多种格式的就用ZipTV吧
老之 2006-10-23
  • 打赏
  • 举报
回复
可以用VCLZIP控件,用法比较简单,去www.2ccc.com下载

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧