C# 解压gizp文件(.tgz)的实例
时间:2020-12-07 17:49:33|栏目:.NET代码|点击: 次
1、引用 SharpCompress.dll
2、代码
using System; using System.IO; using System.Text; using SharpCompress.Reader; using SharpCompress.Common; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { unTAR(@"E:\ConsoleApplication1\ConsoleApplication1\rain.tgz"); Console.WriteLine("Decompress Succeed!"); Console.ReadLine(); } private static string directoryPath = @"E:\ConsoleApplication1\ConsoleApplication1\新建文件夹"; static void unTAR(string tarFilePath) { // UTF7: support chinese font -> UTF.7 SharpCompress.Common.ArchiveEncoding.Default = Encoding.UTF7; using (Stream stream = File.OpenRead(tarFilePath)) { var reader = ReaderFactory.Open(stream); while (reader.MoveToNextEntry()) { if (!reader.Entry.IsDirectory) reader.WriteEntryToDirectory(directoryPath, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite); } } } } }
栏 目:.NET代码
下一篇:ASP.NET MVC5网站开发之业务逻辑层的架构和基本功能 (四)
本文标题:C# 解压gizp文件(.tgz)的实例
本文地址:http://www.codeinn.net/misctech/30428.html