using K4os.Compression.LZ4;
public static void Main()
Console.WriteLine("Hello World");
var httpClient = new HttpClient();
var httpResponse = httpClient.GetAsync("https://myritm.com/Download/Music/320/Mohammad%20Alizadeh%20-%20Dastaane%20Maraa%20Begir.mp3").GetAwaiter().GetResult();
var bytes = httpResponse.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
Console.WriteLine("Finished!");
static void Test(byte[] bytes)
var sizeMB = bytes.Length / 1024 / 1024;
var compressedBytes = Compress(bytes);
var originalBytes = Decompress(compressedBytes);
if (bytes.SequenceEqual(originalBytes) == false) throw new Exception();
Console.WriteLine($"Size : {sizeMB} MB - OK");
Console.WriteLine($"Size : {sizeMB} MB - Exception : {ex.Message}");
static byte[] Compress(byte[] source)
var target = new byte[LZ4Codec.MaximumOutputSize(source.Length)];
var encodedLength = LZ4Codec.Encode(
source, 0, source.Length,
target, 0, target.Length);
return target.Take(encodedLength).ToArray();
static byte[] Decompress(byte[] source)
var target = new byte[source.Length * 255];
var decoded = LZ4Codec.Decode(
source, 0, source.Length,
target, 0, target.Length);
return target.Take(decoded).ToArray();