Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error GZIP header, first magic byte doesn’t match - Decompressing .tar.gz file #794

Open
avasquez-ve opened this issue Feb 8, 2022 · 0 comments

Comments

@avasquez-ve
Copy link

avasquez-ve commented Feb 8, 2022

Hello everyone, I’m trying to decompress a compress file with multiple files on it

the following code works to .tgz filed, but don’t for .tar.gz files

What is wrong here?

FileInfo infoCompressed = new FileInfo(compressedFilePath);
DirectoryInfo destinyDir = new DirectoryInfo(infoCompressed.Directory.ToString());

if (!destinyDir.Exists)
     destinyDir.Create();

using(Stream originFile = new GZipInputStream(infoCompressed.OpenRead()))
{
     using(TarArchive tarFile = TarArchive.CreateInputTarArchive(originFile, TarBuffer.DefaultBlockFactor, Encoding.Default))
     {
          tarFile.ExtractContents(destinyDir.FullName);
     }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant