์• ์ € ํŽ‘์…˜ gzip ์••์ถ• ํ•ด์ œ ํ•˜๋Š”๋ฐ ๋ฐ”์ดํŠธ ํฌ๊ธฐ๊ฐ€ ์ปค์ง€๋‹ˆ๊นŒ (7๋งŒ ์ซŒ ๋„˜์–ด๊ฐ€๋‹ˆ๊นŒ ?)๋ฐ”์ดํŠธ ๋’ค์—๊ฐ€ ์งค๋ฆผ ๊ธธ์ด๊ฐ€ ๋น ๋€Œ๋‚˜?ย 

์•”ํŠผย ์ด๊ฒŒ ์œ ๋‹ˆํ‹ฐ์—์„œ๋Š” ๋˜๋Š”๋ฐ ์• ์ €์—์„  ์•ˆ๋จ


์™œ๊ทธ๋Ÿฐ์ง€ ๋ชฐ๋ผ์„œ ๊ตฌ๊ธ€๋ง ์‚ฝ์งˆํ•˜๋‹ค๊ฐ€ ์–ผ๋–จ๊ฒฐ์— ๊ณ ์นจ

์›๋ž˜ ๊บผ๋ž‘ ๊ณ ์นœ๊ฑฐ๋ž‘ ๊ณต์œ ํ•จ


์›”๋ž˜๊บผ

public static byte[] Decompress(byte[] input)

{

using (var source = new MemoryStream(input))

{

byte[] lengthBytes = new byte[4];

source.Read(lengthBytes, 0, 4);


var length = BitConverter.ToInt32(lengthBytes, 0);

using (var decompressionStream = new GZipStream(source,

CompressionMode.Decompress))

{

var result = new byte[length];

decompressionStream.Read(result, 0, length);

return result;

}

}

}



๊ณ ์นœ๊ฑฐ

public static byte[] Decompress(byte[] input)

{

var source = new MemoryStream(input);

using (var decompressionStream = new GZipStream(source,

CompressionMode.Decompress))

{

int read = 0;

byte[] lengthBytes = new byte[4];

source.Read(lengthBytes, 0, 4);


var length = BitConverter.ToInt32(lengthBytes, 0);


using (MemoryStream output = new MemoryStream())

{

while ((read = decompressionStream.Read(lengthBytes, 0, lengthBytes.Length)) > 0)

{

output.Write(lengthBytes, 0, read);

}

return (output.ToArray());

}


}

}



์™œ๊ทธ๋Ÿฐ์ง€๋Š” ๋‚˜๋‘ ๋ชฐ?๋ฃจ

์•”ํŠผ ํŒŒ์ดํŒ…ํ•ด์–˜๋“ค์•„~~~ ใ…ƒใ…ƒ~~~~