Esempio n. 1
0
 /// <summary>
 /// 压缩
 /// </summary>
 /// <param name="param"></param>
 /// <returns></returns>
 static public string CompressStrZip(string param)
 {
     byte[] data = System.Text.Encoding.UTF8.GetBytes(param);
     //byte[] data = Convert.FromBase64String(param);
     MemoryStream ms = new MemoryStream();
     Stream stream = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(ms);
     try
     {
         stream.Write(data, 0, data.Length);
     }
     finally
     {
         stream.Close();
         ms.Close();
     }
     return Convert.ToBase64String(ms.ToArray());
 }
Esempio n. 2
0
        /// <summary>
        /// 压缩
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        static public string CompressStrZip(string param)
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes(param);
            //byte[] data = Convert.FromBase64String(param);
            MemoryStream ms     = new MemoryStream();
            Stream       stream = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(ms);

            try
            {
                stream.Write(data, 0, data.Length);
            }
            finally
            {
                stream.Close();
                ms.Close();
            }
            return(Convert.ToBase64String(ms.ToArray()));
        }