c# - decompressing compressed binary file -
i have compressed file (binary file/compressed string - i'm not sure is),
i'am trying decompress file c#/vb.net ,
tried decompress gzip:
private shared function gzuncompress(byval data() byte) byte() dim input memorystream = new memorystream(data) dim gzip gzipstream = new gzipstream(input, compressionmode.decompress) dim output memorystream = new memorystream gzip.copyto(output) return output.toarray end function
gzuncompress(new system.net.webclient().downloaddata("http://haxball.com/list3"))
there exception (where : gzip.copyto(output)):
the magic number in gzip header not correct
when tried uncompress php it's worked :) .
php header('content-type: text/html; charset=utf-8'); $list = file_get_contents('http://haxball.com/list3'); $list = gzuncompress($list); $len = implode('', unpack('n*', $list)); $bytes = unpack('c*', $list); $string = implode('', array_map('chr', $bytes)); echo $string;
can check code here:
http://www.compileonline.com/execute_php_online.php
have php's gzuncompress c#/vb.net alternative?
even if there extarnal exe file can same php's gzuncompress function answer,
kind of:
process.start("c:\umcompress.exe -f c:\list3 -o c:\res.txt")
note:a example better explanation
update: first 30 bytes of file:
78 da 8c bd 79 f4 5d d7 55 26 78 65 0d f1 24 0f 89 e3 98 4c 5c 47 21 71 e2 c8 b9 e7 9e e1
that zlib stream. zlib format described in rfc 1950, , consists of two-byte header , four-byte trailer around deflate stream. need write own code process header , trailer, , can use deflatestream class decompress deflate stream.
or can use dotnetzip process zlib stream directly.
Comments
Post a Comment