C# 压缩文件与字节互转

时间:2020-05-07 19:48:28   收藏:0   阅读:72
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);
        }
    }
转载于:https://www.cnblogs.com/aweifly/p/3410865.html

原文:https://www.cnblogs.com/Striveyoungfellow/p/12845075.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!