C#中用SharpZipLib生成gzip/解压文件
2015-10-26 10:40
543 查看
Code tells all:
相关链接:
1、SharpZipLib下载
2、Using SharpZipLib to gzip a file
3、ICSharpCode.SharpZipLib.GZip.GZipInputStream Class Reference
4、C#利用SharpZipLib解压或压缩文件夹实例操作(ZIP格式)
*** walker ***
using System; using System.IO; using ICSharpCode.SharpZipLib.GZip; using ICSharpCode.SharpZipLib.Core; namespace CNKIDataExport { class Program { public static void gZipFile(string filePath, string zipFilePath) { Stream s = new GZipOutputStream(File.Create(zipFilePath)); FileStream fs = File.OpenRead(filePath); int size; byte[] buf = new byte[4096]; do { size = fs.Read(buf, 0, buf.Length); s.Write(buf, 0, size); } while (size > 0); s.Close(); fs.Close(); } public static void gunZipFile(string zipFilePath, string filePath) { using (Stream inStream = new GZipInputStream(File.OpenRead(zipFilePath))) using (FileStream outStream = File.Create(filePath)) { byte[] buf = new byte[4096]; StreamUtils.Copy(inStream, outStream, buf); } } static void Main(string[] args) { string src = @"D:\test\in.txt" string dest = @"D:\test\out.gz" string ori = @"D:\test\ori.txt" gZipFile(src, dest); Console.WriteLine("gzip over!"); gunZipFile(dest, ori); Console.WriteLine("gunzip over!"); Console.ReadKey(); } } }
相关链接:
1、SharpZipLib下载
2、Using SharpZipLib to gzip a file
3、ICSharpCode.SharpZipLib.GZip.GZipInputStream Class Reference
4、C#利用SharpZipLib解压或压缩文件夹实例操作(ZIP格式)
*** walker ***
相关文章推荐
- Linux打包压缩命令
- c#调用COM组件
- C#实现把指定数据写入串口
- C#动态创建button的方法
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- C#中尾递归的使用、优化及编译器优化
- C#实现子窗体与父窗体通信方法实例总结
- C#通用邮件发送类分享
- C#中this的用法集锦
- C#.NET获取拨号连接的宽带连接方法
- C#异步绑定数据实现方法
- C#实现AddRange为数组添加多个元素的方法
- C#中Equality和Identity浅析
- C#生成饼形图及添加文字说明实例代码
- C#判等对象是否相等的方法汇总
- C#简单的向量用法实例教程
- C#实现基于链表的内存记事本实例