# Can't open GZIP file

**URL:** <https://forum.juce.com/t/cant-open-gzip-file/19052>\
**Category:** General JUCE discussion\
**Created:** [September 12, 2016, 10:27am UTC](https://forum.juce.com/t/cant-open-gzip-file/19052 "2016-09-12T10:27:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jnv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jnv/32/11862_2.png) [@Jnv](https://forum.juce.com/u/Jnv)\
**Post date:** [September 12, 2016, 10:27am UTC](https://forum.juce.com/t/cant-open-gzip-file/19052/1 "2016-09-12T10:27:35Z")

</div>

Hello,

I have trouble unzipping GZIP files using either the GZIPDecompressorInputStream or the ZipFile class (the length of the InputStream is -1). Both can’t open [this file](http://www.julien-nevo.com/example.gzip) that was compressed using the GZipStream class from .NET. I have no control over my input files, so I can’t change the compression format.

Is there a way to uncompress such GZIP files using Juce?

Thanks,  
Julien.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [September 12, 2016, 11:52am UTC](https://forum.juce.com/t/cant-open-gzip-file/19052/2 "2016-09-12T11:52:05Z")

</div>

Works for me:

```
int main (int argc, char* argv[])
{

    File gzipFile (File::getSpecialLocation (File::userHomeDirectory).getChildFile ("example.gzip"));
    if (gzipFile.existsAsFile())
    {
        GZIPDecompressorInputStream input (gzipFile.createInputStream(), true, GZIPDecompressorInputStream::gzipFormat);
        jassert (! input.isExhausted());
        
        File outputFile (gzipFile.getParentDirectory().getChildFile ("example"));
        
        outputFile.deleteFile();
        ScopedPointer<OutputStream> output = outputFile.createOutputStream();
        if (output)
            *output << input;
    }

    return 0;
}

```

I think you may be worried by `getTotalLength()` returning -1, but this just indicates that it’s not clear yet how big the decompressed file will be (before it has been decompressed).

---

<div class="post-metadata">

**Author:** ![Jnv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jnv/32/11862_2.png) [@Jnv](https://forum.juce.com/u/Jnv)\
**Post date:** [September 12, 2016, 1:52pm UTC](https://forum.juce.com/t/cant-open-gzip-file/19052/3 "2016-09-12T13:52:12Z")

</div>

Oh sorry, you are right, is it working. I shouldn’t have relied on the `getTotatLength()`. Thanks a lot for the help.
