Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created January 7, 2026 20:07
Show Gist options
  • Select an option

  • Save AnthonyGiretti/21023b6832fc8f0467fec99000d9c0f9 to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyGiretti/21023b6832fc8f0467fec99000d9c0f9 to your computer and use it in GitHub Desktop.
.NET 10 GZip concatenated read + better performance
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Threading.Tasks;
async Task ReadConcatenatedGzipAsync(string path)
{
await using var fileStream = File.OpenRead(path);
await using var gzip = new GZipStream(fileStream, CompressionMode.Decompress);
using var reader = new StreamReader(gzip, Encoding.UTF8);
string content = await reader.ReadToEndAsync();
Console.WriteLine(content);
}
// Works even if the file contains multiple gzip members concatenated + better performance
await ReadConcatenatedGzipAsync("data.gz");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment