์ ์ ํ์ 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());
}
}
}
์๊ทธ๋ฐ์ง๋ ๋๋ ๋ชฐ?๋ฃจ
์ํผ ํ์ดํ ํด์๋ค์~~~ ใ ใ ~~~~
๋๊ธ 0