[英]Create a file within a Zip file in C#
Is it possible to create a file within a Zip file? 是否可以在Zip文件中创建文件?
Let's say I have a file abc.zip
and want to create a file in it named SomeFile.txt
. 假设我有一个文件
abc.zip
并想在其中创建一个名为SomeFile.txt
的文件。 Is it possible? 可能吗? [I am using a dll Ionic.Zip which helps with Zip file manipulation].
[我使用的是一个可帮助Zip文件操作的dll Ionic.Zip]。 Also, I want to do this without unzipping it.
此外,我想执行此操作而不将其解压缩。
Sure. 当然。 For example, if you have already created
SomeFile.txt
: 例如,如果您已经创建了
SomeFile.txt
:
using (var zip = ZipFile.Read("abc.zip"))
{
zip.AddFile("SomeFile.txt");
zip.Save();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.