인터넷에서 다음 코드를 가져와 http://wwwmaster.postgresql.org/download/mirrors-ftp/pgadmin3/release/v1.8.4/src/pgadmin3-1.8.4.tar.gz과 같은 gzip 파일의 압축을 푸는 데 사용하고 있지만 실행하면 예외가 발생합니다. 번호가 일치하지 않습니다..NET에서 gzip 아카이브를 압축 해제 할 때의 문제
public byte[] Download(string pUrl) {
WebClient wc = new WebClient();
byte[] bytes = wc.DownloadData(pUrl);
return UnGzip(bytes, 0);
}
private static byte[] UnGzip(byte[] data, int start) {
int size = BitConverter.ToInt32(data, data.Length - 4);
byte[] uncompressedData = new byte[size];
MemoryStream memStream = new MemoryStream(data, start, (data.Length - start));
memStream.Position = 0;
GZipStream gzStream = new GZipStream(memStream, CompressionMode.Decompress);
try {
gzStream.Read(uncompressedData, 0, size);
} catch (Exception gzError) {
throw;
}
gzStream.Close();
return uncompressedData;
}
이 문제의 원인이되는 코드에는 어떤 것이 있습니까?
바이트 [] 데이터 배열을 가져 오는 코드를 표시 할 수 있습니까? – JaredPar
요청한 것을 추가했습니다. – Ash