DotNetZip:转换的ZipFile为byte []数组 [英] DotNetZip: Convert ZipFile to byte[] array

查看:224
本文介绍了DotNetZip:转换的ZipFile为byte []数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用DotNetZip将文件添加到zip文件,我从文件系统中读取。我想将生成的ZipFile转换为byte []数组。任何援助将高度赞赏。我的代码如下所示。

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


推荐答案

a href =http://msdn.microsoft.com/en-us/library/system.io.file.readallbytes.aspx> File.ReadAllBytes 静态方法 like:

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

return File.ReadAllBytes( shapeFileZip.Name );

从您的文件读取。

这篇关于DotNetZip:转换的ZipFile为byte []数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆