C# · 12月 20, 2021

C# — 文件的压缩与解压(GZipStream)

文件的压缩与解压

需引入 System.IO.Compression;

1.C#代码(入门案例)

Console.WriteLine( (FileStream fr = File.OpenRead( (FileStream fw = File.OpenWrite( (GZipStream gz = [] by = [ * r = fr.Read(by, (r > gz.Write(by,r); r = fr.Read(by,r); Console.WriteLine( Console.WriteLine( (FileStream fr = File.OpenRead( (GZipStream gz = (FileStream fw = File.OpenWrite( [] by = [ * r = gz.Read(by,by.Length); (r > fw.Write(by,r); r = gz.Read(by,r); Console.WriteLine( Console.ReadKey();

2. 运行结果