字节数组到Zip文件

人气:775 发布:2022-09-22 标签: .net c# .NET .NET3.5

问题描述

大家好, 我有一个来自数据库的byte []我需要转换成.zip文件。 请帮助!! 谢谢,小吃 快乐编码

解决方案

字节数组可以是任何东西。它是如何生成的/它包含什么? 如果它是从zip流或zip文件生成的,你只需要用BinaryWriter将它写入磁盘。

尝试:

 File.WriteAllBytes( @  D:\Temp \ Myfile.zip,dataBytesFromDB); 

如果数据是zip文件,则会重新创建它。如果不是,你实际要求的是如何创建一个包含这个字节数组的新zip文件?然后看看这个: http://stackoverflow.com/questions/17217077/create-zip-file -from-byte [ ^

Hi All, I have a byte[] from database which I need to convert into .zip file. Please Help !! Thanks, Tapas "Happy Coding"

解决方案

A byte array can be anything. How was it generated/what does it contain? If it was generated from a zip stream or zip file, you just need to write it to disk with a BinaryWriter.

Try:

File.WriteAllBytes(@"D:\Temp\Myfile.zip", dataBytesFromDB);

If the data is a zip file, this will recreate it. If it isn't, and what you are actually asking for is "how to I create a new zip file containing this array of bytes?" then look at this: http://stackoverflow.com/questions/17217077/create-zip-file-from-byte[^]

727