2023年7月3日发(作者:)
C#解压zip⽂件 因为⼯作中需要在C#项⽬中将多张图⽚⼀次上传,最近两天⼀直在研究,⽹上提供的⽅法很多,整理了⼀下,整合出⼀个⽅法,需要添加引⽤ ,可以在Windowssystem32中找到它。 代码如下:#region 解压zip格式的⽂件 /// /// 功能:解压zip格式的⽂件。 /// /// 压缩⽂件路径 /// 解压⽂件存放路径,为空时默认与压缩⽂件同⼀级⽬录下,跟压缩⽂件同名的⽂件夹 /// 出错信息 /// 解压是否成功 public bool UnZipFile(string zipFilePath, string unZipDir, out string err) { err = ""; if ( == 0) { err = "压缩⽂件不能为空!"; return false; } else if (!th(".zip")) { err = "⽂件格式不正确!"; return false; } else if (!(zipFilePath)) { err = "压缩⽂件不存在!"; return false; } //解压⽂件夹为空时默认与压缩⽂件同⼀级⽬录下,跟压缩⽂件同名的⽂件夹 if ( == 0) unZipDir = e(eName(zipFilePath),eNameWithoutExtension(zipFilePath)); if (!th("")) unZipDir += ""; if (!(unZipDir)) Directory(unZipDir); try { lass sc = new lass(); SrcFolder = ace(zipFilePath); DestFolder = ace(unZipDir); Items items = (); re(items, 20); } catch (Exception ex) { err = e; return false; } return true; }//解压结束 #endregion参考:;
发布者:admin,转转请注明出处:http://www.yc00.com/web/1688382137a129610.html
评论列表(0条)