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
相關文章
相關標籤/搜索