将ZipArchive保存到文件

Folibis

在我的应用程序中,我有一个使用zip归档操作的类System.IO.Compression.ZipArchive现在,我想将存档的条目保存到文件中。我怎样才能做到这一点?我知道我可以将aStream与存档相关联,但在我的情况下,该存档会创建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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章