【发布时间】:2016-01-22 17:50:04
【问题描述】:
我目前正在开发一个 ASP.NET Core 1.0 项目。我想同时留在 dnxcore50 和 dnx451 上。现在让我想到以下问题:
如何将 zip 存档从文件系统解压缩到目录?
"System.IO.FileSystem.Primitives": "4.0.0-beta-22816",
"System.IO.FileSystem": "4.0.0-beta-22816"
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.IO": ""
}
},
"dnxcore50": {
"dependencies": {
"System.IO": "4.0.10-beta-*"
}
}
}
通过 project.json 中的配置,我现在可以获得 GZipStream,但我不知道如何将该流存储到目录中。不幸的是,System.IO.Compression.ZipFile.ExtractToDirectory() 方法中的 ZipFile 对象在核心框架中不存在:/.
更新:
我现在以这种方式包含它并将其从整体依赖项中删除:
"frameworks": {
"dnx451": {
"dependencies": {
"System.IO.Compression.ZipFile": "4.0.1-beta-23516"
}
},
"dnxcore50": {
"dependencies": {
"System.IO.Compression.ZipFile": "4.0.1-beta-23516"
}
}
当我使用核心运行应用程序时,它按预期工作,但使用 .net 框架 4.6 运行它时,我在运行时崩溃并出现以下异常:
处理请求时发生n个未处理的异常。
An unhandled exception occurred while processing the request.
FileNotFoundException: Could not load file or assembly 'System.IO.Compression.ZipFile, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
【问题讨论】:
-
嗯,are you sure?
-
感谢您的回答。我发现了我的错误。我使用了 System.IO.Compression.ZipFile 4.0.0 的最后一个稳定版本,但它似乎已添加到 4.0.1-beta-23516 @JoachimIsaksson
-
更新了我的问题。你能再帮我一次吗? @JoachimIsaksson
标签: c# .net zip asp.net-core .net-core