我有以下代码解压缩给变量zipFileName
的bz2文件,我想将代码更改为在.bz2文件中存在的相同文件夹/文件结构中解压缩?请建议如何执行该操作
using System;
using System.IO;
using ICSharpCode.SharpZipLib.BZip2;
class Program
{
static void Main(string[] args)
{
var zipFileName = @"C:\Temp\bins-hw.2.tar.bz2";
using (FileStream fileToDecompressAsStream = System.IO.File.OpenRead(zipFileName))
{
string decompressedFileName = @"C:\Temp\ichsarp\decompressed.txt";
using (FileStream decompressedStream = File.Create(decompressedFileName))
{
try
{
BZip2.Decompress(fileToDecompressAsStream, decompressedStream, true);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
}