using (ZipFile zip = ZipFile.Read(fu.PostedFile.InputStream)){
string extractPath = Server.MapPath("~/Uploads/");
string oldPathImg = Server.MapPath("~/Uploads/RubbishData/");
zip.ExtractSelectedEntries("name = *.docx", "",extractPath, ExtractExistingFileAction.OverwriteSilently);
var x = zip.ExtractSelectedEntries("name = *.png");
}
最后一行给出了错误“无法将void分配给隐式类型的局部变量”,我不明白为什么。
答案 0 :(得分:0)
正如我的评论中所提到的,您使用的库有Ionic API Guide,它明确指出ExtractSelectedEntries
的所有重载都没有返回类型,只是void
public void ExtractSelectedEntries(
string selectionCriteria,
ExtractExistingFileAction extractExistingFile
)
这意味着你的代码应该是这样的
using (ZipFile zip = ZipFile.Read(fu.PostedFile.InputStream)){
string extractPath = Server.MapPath("~/Uploads/");
string oldPathImg = Server.MapPath("~/Uploads/RubbishData/");
zip.ExtractSelectedEntries("name = *.docx", "",extractPath, ExtractExistingFileAction.OverwriteSilently);
zip.ExtractSelectedEntries("name = *.png"); // Cannot assign void to a variable, remove the assignment.
}