在我的应用程序中,我有一个使用 System.IO.Compression.ZipArchive
处理 zip 存档的类。
现在我想将存档的条目保存到文件中。我怎样才能做到这一点?我知道我可以将 Stream
与存档相关联,但在我的例子中,存档创建了 w/o 流,我无法更改代码:
var archive = ZipFile.Open(fileName, ZipArchiveMode.Create);
// add entries
// how can I save it to file now?
最佳答案
您已经“将其保存到一个文件”,即由 fileName
指示的文件。
要确保所有内容都已写入并刷新,请使用 using
:
using (var archive = ZipFile.Open(fileName, ZipArchiveMode.Create))
{
// add entries
....
} // here it is saved and closed
关于c# - 将 ZipArchive 保存到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42488879/