C# 解压gizp文件(.tgz)的实例
1、引用SharpCompress.dll
2、代码
usingSystem; usingSystem.IO; usingSystem.Text; usingSharpCompress.Reader; usingSharpCompress.Common; namespaceConsoleApplication1 { classProgram { staticvoidMain(string[]args) { unTAR(@"E:\ConsoleApplication1\ConsoleApplication1\rain.tgz"); Console.WriteLine("DecompressSucceed!"); Console.ReadLine(); } privatestaticstringdirectoryPath=@"E:\ConsoleApplication1\ConsoleApplication1\新建文件夹"; staticvoidunTAR(stringtarFilePath) { //UTF7:supportchinesefont->UTF.7 SharpCompress.Common.ArchiveEncoding.Default=Encoding.UTF7; using(Streamstream=File.OpenRead(tarFilePath)) { varreader=ReaderFactory.Open(stream); while(reader.MoveToNextEntry()) { if(!reader.Entry.IsDirectory) reader.WriteEntryToDirectory(directoryPath, ExtractOptions.ExtractFullPath|ExtractOptions.Overwrite); } } } } }
以上这篇C#解压gizp文件(.tgz)的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。