Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8606317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:03:46+00:00 2026-06-12T03:03:46+00:00

i have a C# application where i am using SharpZipLib to deflate a very

  • 0

i have a C# application where i am using SharpZipLib to deflate a very long string and then send the data over to a PHP Service in a Base64 string of the deflated byte[].

For some reason, when trying to Inflate it on the PHP side, it is returning an error: ‘gzinflate: data error’.

How to inflate a gzipped string in PHP?

Here is the C# code:

    byte[] sIn = System.Text.UTF8Encoding.UTF8.GetBytes(data);

    MemoryStream rawDataStream = new MemoryStream();
    GZipOutputStream gzipOut = new GZipOutputStream(rawDataStream);
    gzipOut.IsStreamOwner = false;

    gzipOut.Write(sIn, 0, sIn.Length);
    gzipOut.Close();

    byte[] compressed = rawDataStream.ToArray();

    // data sent to the php service
    string b64 = Convert.ToBase64String(compressed);

PHP code:

    $inflated = base64_decode($_POST['data']);

    // crash here
    $inflated = gzinflate($inflated);

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:03:47+00:00Added an answer on June 12, 2026 at 3:03 am

    Can’t really say why it fails for you with GZipOutStream though I’m guessing it is doing something else then just a pure deflate-compression. I changed your code to use DeflateStream from System.IO.Compression instead and then it worked like a charm.

    byte[] sIn = UTF8Encoding.UTF8.GetBytes("testing some shit");
    
    MemoryStream rawDataStream = new MemoryStream();
    DeflateStream gzipOut = new DeflateStream(rawDataStream, CompressionMode.Compress);
    
    gzipOut.Write(sIn, 0, sIn.Length);
    gzipOut.Close();
    
    byte[] compressed = rawDataStream.ToArray();
    
    // data sent to the php service
    string b64 = Convert.ToBase64String(compressed);
    

    Edit

    Since the question was about using compression for a Windows Phone project I tried using the DeflateStream from SharpCompress as well and it works just fine, you just have to change which namespace you are using, the classes are the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Silverlight application using NHibernate as a ORM. I have projects for Data(mapp
I have an application using Hibernate for data persistence, with Spring on top (for
I have an application using TTS very heavily. It's working fine, but I need
I have a very weird problem. Have an application using Hibernate and spring.I have
I have an application using QtWebKit. It loads URLs and exports some stats on
I have an application using FeedbackPanel to show the user the results of posting
We have an application using the IBM Informix driver. Whenever we try to open
I have an application using the Google Maps javscript API and the Infobox plug-in
I have an application using LINQ-to-SQL with SQL Server CE 4. I know that
I have an application written using C++ Builder 5 that uses the TDocument class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.