离子邮编:从字节Zip文件的创建[] [英] Ionic Zip : Zip file creation from byte[]
问题描述
离子拉链让我现有的文件添加到压缩对象,并创建一个zip文件。但考虑到我正在读的字节[]从创建压缩文件,发送过的服务器,我需要重新创建到服务器上的存储压缩该字节[] zip文件。我如何做到这一点?
Ionic zip allows me to add existing file to zip object and create a zip file. But considering that I am reading those byte[] from created zip file and sending over server, I need to again create zip file from that byte[] to store zip on server. How do I achieve this ?
我使用C#。
推荐答案
如果我没有理解你的问题,你会得到你的字节[]
数据阵列在网络上,并要保存zip文件的数据?您可以创建一个新的的ZipEntry
从的MemoryStream
你从创建字节[]
你有(如文档所示):
If I understand your question correctly, you get your byte[]
data array over the network and want to save that data in a zip file? You can create a new ZipEntry
from a MemoryStream
which you create from the byte[]
you got (as shown in the docs):
byte[] data = MethodThatReceivesYourDataOverTheNet();
using (MemoryStream stream = new MemoryStream(data))
{
using (ZipFile zip = new ZipFile())
{
zip.AddEntry("name_of_the_file_in_the_arhive.bin", "base", stream);
zip.Save("example.zip");
}
}
这篇关于离子邮编:从字节Zip文件的创建[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!