DotNetZip: Convert ZipFile to byte[] array

余生长醉 提交于 2019-12-12 11:27:58

问题


I'm using DotNetZip to add a file to a zip archive, which I've read from the file system. I'd like to convert the resulting ZipFile to byte[] array. Any assistance will be highly appreciated. My code is shown below.

public byte[] AddPrjFile(FileStream shapeFileZip, Uri prjLocation)
    {
        string prjFileAbsPath = prjLocation.AbsolutePath;
        using (ZipFile zip = ZipFile.Read(shapFileZip))
        {
            ZipEntry e = zip.AddFile(prjFileAbsPath);
            e.FileName = zipFile.Name + ".prj";
        }

   return byte_array;
}

回答1:


You could simply use the File.ReadAllBytes static method like:

return File.ReadAllBytes( shapeFileZip.Name );

To read from your file.



来源:https://stackoverflow.com/questions/11119705/dotnetzip-convert-zipfile-to-byte-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!