String To Byte Serialization /ZIP

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 1190
public static byte[] ConvertAndCompressStringToBytes(string xmlstring)
{
MemoryStream ms = new MemoryStream();
byte[] xmlAsBytes = Encoding.Unicode.GetBytes(xmlstring);
GZipStream compressedzipStream = new GZipStream(ms, CompressionMode.Compress, true);
compressedzipStream.Write(xmlAsBytes, 0, xmlAsBytes.Length);
compressedzipStream.Close();
return ms.ToArray();
}

Comments or Responses

Login to post response