我正在使用DotNetZip将文件添加到zip存档中,我已从文件系统中读取该文件。我想将生成的ZipFile转换为byte []数组。任何帮助将受到高度赞赏。我的代码如下所示。
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;
}
答案 0 :(得分:13)
你可以简单地使用File.ReadAllBytes
static method之类的:
return File.ReadAllBytes( shapeFileZip.Name );
从您的文件中读取。