当前位置: 移动技术网 > IT编程>开发语言>c# > C# 解压gizp文件(.tgz)的实例

C# 解压gizp文件(.tgz)的实例

2019年07月18日  | 移动技术网IT编程  | 我要评论
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)的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网