Ionic Zip : Zip file creation from byte[]

后端 未结 2 1389
眼角桃花
眼角桃花 2021-02-15 15:59

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 nee

2条回答
  •  忘掉有多难
    2021-02-15 16:21

    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");
        }
    }
    

提交回复
热议问题