User (Old forums)MemberNovember 28, 2006 at 12:50 pmPost count: 23064
Is it possible to retrieve the decompression ratio from a gzipped file in Xceed Zip?
I would like to be able to roughly estimate the size of a gzipped file after it is decompressed. The Visual Studio fileinfo.Length property returns the size of the compressed file, so knowing the decompression ratio would allow me to compute the file size to an accuracy sufficien for my purposes. Decompression ratio is displayed by every zip utility I know, so it must be available, but I’m not sure how to retrieve it in Xceed Zip. It doesn’t appear to be a property of the GZipHeader class.
Imported from legacy forums. Posted by fredr (had 3132 views)User (Old forums)MemberNovember 30, 2006 at 8:25 amPost count: 23064
You are mentioning GZippedFile, but you also mention .Length, so I’m not sure what you are doing exactly. One refers to a file within a GZip archive, the other refers to a stream compression format.
If you are using a GZippedFile, thus a file within a GZip archive, you can use the Size property to know the uncompressed size of the file.
If you are using GZipCompressedStream, then the Length property will not work, because the stream must be seekable for the length property to work (see .NET documentation on Stream), and the GZipCompressedStream is not seekable. But even if it would work, it would represent the compressed size.
In sum, thus there is no means to know the uncompressed size of a compressed stream.
Imported from legacy forums. Posted by André (had 219 views)User (Old forums)MemberNovember 30, 2006 at 1:39 pmPost count: 23064
That’s interesting. since the Length property is clearly stated to be a member of the GZipCompressedStream class.
What I’m doing is, as defined in your online help, is defining a GZipCompressedStream around a GZip file from a source FileStream, then reading and writing successive buffers. I need to split the output into several uncompressed files, whose size is a predfined fraction of the original uncompressed file’s size. For now I have manually inspected the compression ration and used that to get a rough file size, but I’d like to do that automatically for each file.
I don’t see a definition for “GZippedFile” or “GZip archive” that doesn’t refer to the GZipCompressedStream class, so I’m not sure how to access the information you mention. If I can’t get the size, is the compression ratio available? I didn’t see it as a GZipHeader property.
Imported from legacy forums. Posted by fredr (had 252 views)User (Old forums)MemberNovember 30, 2006 at 3:24 pmPost count: 23064
Length is a member of Stream, and since our streams inherit from Stream, it is listed as a member of our streams.
There is a difference between a compression format and a file format.
GZipCompressedStream is a compression format used to compress data. It does not build a file in and of itself. It is a format of compression, that’s it, and a stream is used to do the actual compression/decompression.
GZip is a file format, just like Zip is a file format, and not only a compression format. GZipArchive is a class that represent a GZip file. You may or may not have access to it, depending on the version of Xceed Zip for .NET you have, since we have added support for it only recently. GZipCompressedStream has been available for a long time in our product, and this is why you have access to it, and not necessarily to the other.
So has I stated earlier, Size is available on GZippedFile (a file in a GZip archive), but not on GZipCompressedStream, because it is not part of this compression format. With the GZip compression format you will not be able to know the uncompressed size, unless you uncompress it first. Which is of course counter productive.
In sum, if what you have is data that is compressed using GZip compression format, and not a GZip archive, you will not be able to get uncompress size or ratio. To get this type of information in the headers of a file, you need to use a Zip archive.
Imported from legacy forums. Posted by André (had 4195 views)
- You must be logged in to reply to this topic.