-->

DotNetZip:转换的ZipFile为byte []数组(DotNetZip: Convert

2019-09-18 07:22发布

我使用DotNetZip将文件添加到一个zip压缩包,我已经从文件系统读取。 我想将所得的ZipFile转换为字节[]数组。 任何援助将得到高度赞赏。 我的代码如下所示。

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

Answer 1:

你可以简单地使用File.ReadAllBytes静态方法 ,如:

return File.ReadAllBytes( shapeFileZip.Name );

若要从文件中读取。



文章来源: DotNetZip: Convert ZipFile to byte[] array