C# 压缩文件与字节互转

public class ZipBin
    {
        public byte[] bytes;
        //C#读取压缩文件(将压缩文件转换为二进制
        public void GetZipToByte(string inpath)
        {
            FileStream fs = new FileStream(inpath, FileMode.Open);
            bytes = new byte[fs.Length];
            int count = Convert.ToInt32(fs.Length);
            fs.Read(bytes, 0, count);
        }

        //C#将二进制转换为压缩文件
        public void GetByteToZip(string outpath)
        {
            string path = outpath;//压缩文件的地址 
            File.WriteAllBytes(path, bytes);
        }
    }
View Code
原文地址:https://www.cnblogs.com/aweifly/p/3410865.html