Good day,
I have a code as follows to compress I just copied it from the documentation:
private string CompressString(string str)
{
MemoryStream memoryStream = new MemoryStream();
ZipCompression method = ZipCompression.Default;
ZipOutputStream zipOutputStream = new ZipOutputStream(memoryStream, method);
StreamWriter writer = new StreamWriter(zipOutputStream);
writer.Write(str);
writer.Flush();
return Convert.ToBase64String(memoryStream.ToArray());
}
What is missing is to decompress it, I tried the following code but it doesn't give me the correct output
private string UnCompressString(string str)
{
MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(str));
ZipInputStream input = new ZipInputStream(memoryStream);
StreamReader reader = new StreamReader(input.BaseStream);
string strData = reader.ReadToEnd();
return strData;
}
When I tried to call the uncompressstring method, it does not give me the original text.
Thanks
I have a code as follows to compress I just copied it from the documentation:
private string CompressString(string str)
{
MemoryStream memoryStream = new MemoryStream();
ZipCompression method = ZipCompression.Default;
ZipOutputStream zipOutputStream = new ZipOutputStream(memoryStream, method);
StreamWriter writer = new StreamWriter(zipOutputStream);
writer.Write(str);
writer.Flush();
return Convert.ToBase64String(memoryStream.ToArray());
}
What is missing is to decompress it, I tried the following code but it doesn't give me the correct output
private string UnCompressString(string str)
{
MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(str));
ZipInputStream input = new ZipInputStream(memoryStream);
StreamReader reader = new StreamReader(input.BaseStream);
string strData = reader.ReadToEnd();
return strData;
}
When I tried to call the uncompressstring method, it does not give me the original text.
Thanks