Unzipping a .gz file using C#

后端 未结 3 1575
醉话见心
醉话见心 2020-11-29 10:00

I have a tarred gunzip file called ZippedXmls.tar.gz which has 2 xmls inside it. I need to programmatically unzip this file and the output should be 2 xmls copied in a folde

3条回答
  •  旧巷少年郎
    2020-11-29 10:39

    I know this question is ancient, but search engines redirect here for how to extract gzip in C#, so I thought I'd provide a slightly more recent example:

    using (var inputFileStream = new FileStream("c:\\myfile.xml.gz", FileMode.Open))
    using (var gzipStream = new GZipStream(inputFileStream, CompressionMode.Decompress))
    using (var outputFileStream = new FileStream("c:\\myfile.xml", FileMode.Create))
    {
        await gzipStream.CopyToAsync(outputFileStream);
    }
    

    For what should be the simpler question of how to untar see: Decompress tar files using C#

提交回复
热议问题