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();
}