You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: Add APIs to System.IO.Compression that can open compressed tar archives like tar.gz #70517
If we want to add APIs that can handle archives compressed with gzip (or any compression algorithm), we should add them to System.IO.Compression. I am opening this issue to initiate the discussion.
TarEntry?entry=null;using(varsourceStream=File.Open(Source,FileMode.Open,FileAccess.ReadWrite,FileShare.ReadWrite)){usingvarreader=newTarReader(sourceStream);try{entry=reader.GetNextEntry();}catch{// It is not tar archive. Go to next format detection.}}if(entryis not null){TarFile.ExtractToDirectory(Source,ToDirectory,Otherwrite);return;}using(varsourceStream=File.Open(Source,FileMode.Open,FileAccess.Read,FileShare.Read)){usingvardecompressorStream=newGZipStream(sourceStream,CompressionMode.Decompress);usingvarreader=newTarReader(decompressorStream);try{entry=reader.GetNextEntry();}catch{// It is not tar archive. Go to next format detection.}}if(entryis not null){usingvarsourceStream=File.Open(Source,FileMode.Open,FileAccess.Read,FileShare.Read);usingvardecompressorStream=newGZipStream(sourceStream,CompressionMode.Decompress);TarFile.ExtractToDirectory(decompressorStream,ToDirectory,Otherwrite);return;}ExtractZipToDirectory(this,Source,ToDirectory,Encoding,Otherwrite);
Notice, we have to put Zip detection on last place - after .gz
changed the title [-][API Proposal]: Add APIs to `System.IO.Compression` that can compressed `tar` archives like `tar.gz`[/-][+][API Proposal]: Add APIs to `System.IO.Compression` that can open compressed `tar` archives like `tar.gz`[/+]on Oct 15, 2025
Activity
iSazonov commentedon Aug 18, 2022
Example of code to extract an archive:
Notice, we have to put Zip detection on last place - after .gz
[-][API Proposal]: Add APIs to `System.IO.Compression` that can compressed `tar` archives like `tar.gz`[/-][+][API Proposal]: Add APIs to `System.IO.Compression` that can open compressed `tar` archives like `tar.gz`[/+]