DotNetZip:如何提取文件,但忽略了zip文件的路径? [英] DotNetZip: How to extract files, but ignoring the path in the zipfile?

查看:245
本文介绍了DotNetZip:如何提取文件,但忽略了zip文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图提取文件到指定文件夹忽略了zip文件的路径,但似乎没有成为一个方式。



这似乎给出一个相当基本要求。所有其他的好东西在里面实施



我失去了什么。



码是? -

 使用(Ionic.Zip.ZipFile ZF = Ionic.Zip.ZipFile.Read(zipPath))
{
zf.ExtractAll(APPPATH);
}


解决方案

您需要删除文件名的只是解压...

 使用(VAR ZF = Ionic.Zip.ZipFile.Read前的目录部分( zipPath))
{
zf.ToList()的ForEach(入门=方式>
{
entry.FileName = System.IO.Path.GetFileName(entry.FileName);
entry.Extract(APPPATH);
});
}


Trying to extract files to a given folder ignoring the path in the zipfile but there doesn't seem to be a way.

This seems a fairly basic requirement given all the other good stuff implemented in there.

What am i missing ?

code is -

using (Ionic.Zip.ZipFile zf = Ionic.Zip.ZipFile.Read(zipPath))
{
    zf.ExtractAll(appPath);
}

解决方案

You'll need to remove the directory part of the filename just prior to unzipping...

using (var zf = Ionic.Zip.ZipFile.Read(zipPath))
{
    zf.ToList().ForEach(entry =>
    {
        entry.FileName = System.IO.Path.GetFileName(entry.FileName);
        entry.Extract(appPath);
    });
}

这篇关于DotNetZip:如何提取文件,但忽略了zip文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆