C# 解压gizp文件(.tgz)的实例
程序员文章站
2024-02-11 21:08:22
1、引用 sharpcompress.dll
2、代码
using system;
using system.io;
using system.text;...
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); } } } } }
以上这篇c# 解压gizp文件(.tgz)的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。