1

I have a method:

public static string UnZipStr(byte[] input)
{
    if (input == null){
        return null;
    }
    using (MemoryStream inputStream = new MemoryStream(input))
    using (DeflateStream gzip = new DeflateStream(inputStream, CompressionMode.Decompress))
    using (StreamReader reader = new StreamReader(gzip, System.Text.Encoding.UTF8))
    {
        return reader.ReadToEnd();
    }
}

But I always get xml text unzipping, it is fact. I need to change this method in order to return SqlXml object. Unfortunate I'm java developer and cannot solve this task.

1 Answer 1

1

Do you need a SqlXml object or an XmlDocument/XDocument object? This post about converting a SqlXml object into an XmlDocument may be related to your needs.

You may be able to do the following:

public static string SqlXmlFromZippedBytes(byte[] input)
{
    if (input == null){
        return null;
    }
    using (MemoryStream inputStream = new MemoryStream(input))
    using (DeflateStream gzip = new DeflateStream(inputStream, CompressionMode.Decompress))
    using (StreamReader reader = new StreamReader(gzip, System.Text.Encoding.UTF8))
    {
        return new SqlXml(reader); // From System.Data.SqlTypes
    }
}

Here is the documentation on the SqlXml constructor.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.