C#解压GZ文件
2016-04-12 15:14
603 查看
public void ungzip(string path, string decomPath, bool overwrite) { //for overwriting purposes if (File.Exists(decomPath)) { if (overwrite) { File.Delete(decomPath); } else { throw new IOException("The decompressed path you specified already exists and cannot be overwritten."); } } //create our file streams GZipStream stream = new GZipStream(new FileStream(path, FileMode.Open, FileAccess.ReadWrite), CompressionMode.Decompress); FileStream decompressedFile = new FileStream(decomPath, FileMode.OpenOrCreate, FileAccess.Write); //data represents a byte from the compressed file //it's set through each iteration of the while loop int data; while ((data = stream.ReadByte()) != -1) //iterates over the data of the compressed file and writes the decompressed data { decompressedFile.WriteByte((byte)data); } //close our file streams decompressedFile.Close(); stream.Close(); }
相关文章推荐
- C# 如何在Excel 动态生成PivotTable
- C# 开启摄像头 拍照
- C# 订单流水号生成
- c#压缩和解压缩
- C# 利用ZedGraph控件画简单折线图示例
- C#自动实现Dll(OCX)控件注册的两种方法
- C#使用Cookie方法
- c#代码规范和质量检查工具这点事
- c# string 数组转 list
- C# Winform 删除信息提示
- C# 中的委托和事件
- C# Email发送
- C#文件操作
- c#指针和寻址运算
- [C#] 静态方式实现的单例是不是懒汉模式?
- C#界面控件DotNetBar使用详解
- c#程序内存分配
- myself C# template 格式规范
- WindowsCE project missing Microsoft.CompactFramework.CSharp.targets in Visual Studio 2008
- [转]C# 线程知识--使用Task执行异步操作