请教各位专家,压缩包使用VCLzip解压后文件名变成乱码。

z15874666325 2018-02-28 05:20:35


如图,请教各位专家,压缩包使用VCLzip解压后文件名变成乱码。

var
M:TMemoryStream;

procedure TFormDownload.Download(Url:String);
begin
M:=TMemoryStream.Create;
try
try
Self.IdHTTP1.Get(Url,M);
except
end;

ForceDirectories(ExtractFileDir(Application.ExeName)+'\DownTemp');
if DirectoryExists(ExtractFileDir(Application.ExeName)+'\DownTemp') then
begin
M.SaveToFile(ExtractFileDir(Application.ExeName)+'\DownTemp\Rain.zip');
// Self.VCLUnZip1.ZipName:=ExtractFileDir(Application.ExeName)+'\DownTemp\Rain.zip';

M.Position:=0;
Self.VCLUnZip1.ArchiveStream:=M;
Self.VCLUnZip1.OverwriteMode:=Always;
Self.VCLUnZip1.ReadZip;
Self.VCLUnZip1.FilesList.Add('*.*');
Self.VCLUnZip1.DestDir:=ExtractFileDir(Application.ExeName)+'\DownTemp\';
Self.VCLUnZip1.DoAll := true;
Self.VCLUnZip1.RecreateDirs := true;
Self.VCLUnZip1.RetainAttributes := True;
Self.VCLUnZip1.UnZip;
Self.Timer.Enabled:=false;
end;
finally
FreeAndNil(M);
end;
Self.IdHTTP1.Disconnect;
end;
...全文
1125 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
frtrnr 2018-03-01
  • 打赏
  • 举报
回复
涉及到utf8toansi吧
bwsoft1 2018-03-01
  • 打赏
  • 举报
回复
function JyUnZipFiles(MyZipName, MyDestDir: string; var msg: string; password: string = ''; zipControl: TVCLZip = nil; afn: string = ''; astream: tstream = nil): Boolean; var // zipControl: TVCLZip; count: Integer; isnil: Boolean; r: Integer; begin result := false; msg := '未定义错误'; if zipControl = nil then isnil := true else isnil := false; MyZipName := trim(MyZipName); if MyZipName = '' then begin msg := '文件名为空!'; raise Exception.Create(msg); exit; end; MyZipName := trim(MyZipName); if FileExists(MyZipName) = false then begin msg := '文件不存在!' + MyZipName; raise Exception.Create(msg); exit; end; if astream = nil then begin MyDestDir := trim(MyDestDir); if MyDestDir = '' then begin msg := '目录名为空!'; raise Exception.Create(msg); exit; end; if DirectoryExists(MyDestDir) = false then begin ForceDirectories(MyDestDir); Application.ProcessMessages; end; if DirectoryExists(MyDestDir) = false then begin msg := '目录不能被建立!'; raise Exception.Create(msg + MyDestDir); exit; end; end; // try if isnil then zipControl := TVCLZip.Create(Application); try zipControl.password := password; zipControl.ZipName := MyZipName; zipControl.ReadZip; count := zipControl.count; if MyDestDir = '' then begin if afn = '' then begin afn := zipControl.Pathname[0] + zipControl.FileName[0]; end; end; // jymessagebox(zipControl.Filename[3]); zipControl.DestDir := MyDestDir; zipControl.OverwriteMode := Always; zipControl.RelativePaths := true; zipControl.RecreateDirs := true; zipControl.FilesList.clear; if afn = '' then begin zipControl.doall := true; zipControl.FilesList.Add('*.*'); if zipControl.UnZip = count then begin result := true; msg := '成功'; end else begin msg := '解压失败!'; raise Exception.Create(msg); end; end else begin // zipControl.UnZipToStream() zipControl.doall := false; // true; zipControl.FilesList.Add(afn); if astream = nil then r := zipControl.UnZip else begin astream.size := 0; r := zipControl.UnZipToStream(astream, afn); astream.Position := 0; end; if r = 1 then begin result := true; msg := '成功'; end else begin msg := '解压失败!'; raise Exception.Create(msg); end; end; // zipControl.FilesList.add('*.*'); //'\费劲阿斯克的积分\房交会说反话\挥发物巨额罚金\小贵子_3.jpg' finally if isnil then begin zipControl.Free; zipControl := nil; end; end; // except // on e: Exception do // begin // msg := e.Message; // end; // end; end; 没发现有乱码情况

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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