The last 4 bytes of the gz file contains the length So it should be something like: using(var fs = File. OpenRead(path)) { fs. Position = fs.
Length - 4; var be = new byte4; fs. Read(b, 0, 4); uint length = BitConvertor. ToUInt32(b, 0); Console.
WriteLine(length); }.
The last 4 bytes of the gz file contains the length. So it should be something like: using(var fs = File. OpenRead(path)) { fs.
Position = fs. Length - 4; var be = new byte4; fs. Read(b, 0, 4); uint length = BitConvertor.
ToUInt32(b, 0); Console. WriteLine(length); }.
Jan 12 at 7:47 Thanks Leppie... actually in my case the file will be less than 4GB... Thanks for your help... – Ummar Jan 12 at 13:54.
The last for bytes of a . Gz file are the uncompressed input size modulo 2^32. If your uncompressed file isn't larger than 4GB, just read the last 4 bytes of the file.
If you have a larger file, I'm not sure that it's possible to get without uncompressing the stream.
EDIT: See the answers by Leppie and Gabe; the only reason I'm keeping this (rather than deleting it) is that it may be necessary if you suspect the length is > 4GB For gzip, that data doesn't seem to be directly available - I've looked at GZipStream and the SharpZipLib equivalent - neither works. The best I can suggest is to run it locally: long length = 0; using(var fs = File. OpenRead(path)) using (var gzip = new GZipStream(fs, CompressionMode.
Decompress)) { var buffer = new byte10240; int count; while ((count = gzip. Read(buffer, 0, buffer. Length)) > 0) { length += count; } } If it was a zip, then SharpZipLib: long size = 0; using(var zip = new ZipFile(path)) { foreach (ZipEntry entry in zip) { size += entry.
Size; } }.
– Ummar Jan 12 at 7:40 @Ummar: Both Gabe and myself explained the 'correct' way of doing this. The above way will work, but imagine using it on 1000's of 2GB files, it will take forever. – leppie Jan 12 at 7:46 @Ummar - see @leppie's answer – Marc Gravell?
Jan 12 at 7:47 Thanks, Leppie solution worked for me perfectly... – Ummar Jan 12 at 13:55.
Public static long mGetFileLength(string strFilePath) { if (!string. IsNullOrEmpty(strFilePath)) { System.IO. FileInfo info = new System.IO.
FileInfo(strFilePath); return info. Length; } return 0; }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.