问题描述
我试图用 DotNetZipLib的devkit-V1.9
在我MVC3项目将文件解压到一个特定的文件夹。
I'm trying to use DotNetZipLib-DevKit-v1.9
in my MVC3 Project to extract the files to a specific folder.
我要的是 - 如何 zip.SelectEntries
方法添加多个条目。
What i want is -- How to add multiple entries in zip.SelectEntries
method.
下面是我的code在控制器动作:
Here is my code in controller action:
public ActionResult ExtractZip(string fileName, HttpPostedFileBase fileData)
{
string zipToUnpack = @"C:\Users\Public\Pictures\Sample Pictures\images.zip";
string unpackDirectory = System.IO.Path.GetTempPath();
using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
{
// here, we extract every entry, but we could extract conditionally
// based on entry name, size, date, checkbox status, etc.
var collections = zip1.SelectEntries("name=*.jpg;*.jpeg;*.png;*.gif;");//This shows `0` items in collections
foreach (var item in collections)
{
item.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
}
}
return Json(true);
}
在此行 VAR集合= zip1.SelectEntries(NAME = * JPG; * JPEG; *。png格式; *。GIF;);
如果我仅指定一个延伸,它工作正常。
In this line var collections = zip1.SelectEntries("name=*.jpg;*.jpeg;*.png;*.gif;");
if i specify only single extension ,it works fine
例如: VAR集合= zip1.SelectEntries(NAME = * GIF。);
这工作好
我也看到SelectEntries方法<一href=\"http://help.infragistics.com/Help/NetAdvantage/Silverlight/2012.2/CLR4.0/html/InfragisticsSL5.Com$p$pssion.v12.2~Infragistics.Com$p$pssion.ZipFile~SelectEntries%28String%29.html\"相对=nofollow>这里,但它并不能帮助虽然
I've also seen SelectEntries method here, but it doesn't help though
如何添加多个条目?
推荐答案
最后我能回答我的问题。
Finally i could answer my own question.
中序选择,我们需要使用或
键,可选择多个条目使用以下code多个条目:
Inorder to select multiple entries we need to use OR
and to select multiple entries use the following code:
var collections = zip1.SelectEntries("(name=*.jpg) OR (name=*.jpeg) OR (name=*.png) OR (name=*.gif)");
foreach (var item in collections)
{
item.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
}
这篇关于无法获得DotNetZip的SelectEntries多个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!