Пример #1
0
        /// <summary>
        /// 将二进制解压缩为数据集
        /// </summary>
        /// <param name="byteSource">预解压缩的二进制</param>
        /// <returns>解压缩后的数据集</returns>
        public static DataSet DecompressDataSet(byte[] byteSource)
        {
            DataSet         curSet = new DataSet();
            BinaryFormatter bf     = new BinaryFormatter();

            byte[] DeData = OPZLib.DecompressBytes(byteSource);
            using (MemoryStream ms = new MemoryStream(DeData))
                curSet = bf.Deserialize(ms) as DataSet;

            return(curSet);
        }
Пример #2
0
 /// <summary>
 /// 压缩数据集为二进制
 /// </summary>
 /// <param name="curSet">在压缩的数据集</param>
 /// <returns>压缩成的二进制</returns>
 public static byte[] CompressDataSet(DataSet curSet)
 {
     byte[] e2 = null;
     using (MemoryStream ms = new MemoryStream())
     {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(ms, curSet);
         e2 = OPZLib.CompressBytes(ms.GetBuffer());
     }
     return(e2);
 }