/// <summary> /// 把压缩后的字节数组 解压并反序列化成DataSet /// </summary> /// <param name="byteArray"></param> /// <returns>DataSet</returns> public static DataSet GetDataSetByZipBytes(byte[] byteArray) { DataSetSurrogate sds = null; MemoryStream _MemoryStream = new MemoryStream(Decompress(byteArray)); BinaryFormatter _BinaryFormatter = new BinaryFormatter(); object o = _BinaryFormatter.Deserialize(_MemoryStream); sds = (DataSetSurrogate)o; return(sds.ConvertToDataSet()); }
public static DataTable arrByteToDataTable(byte[] zipBuffer) { if (zipBuffer == null || zipBuffer.Length < 1) { return(null); } byte[] buffer = UnZipClass.Decompress(zipBuffer); BinaryFormatter ser = new BinaryFormatter(); DataSetSurrogate dss = ser.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate; DataSet dataSet = dss.ConvertToDataSet(); return(dataSet.Tables[0]); }
private void button3_Click(object sender, EventArgs e) { WebServices.SOAPTEST.SOAPTEST ds = new WebServices.SOAPTEST.SOAPTEST(); DateTime dtBegin = DateTime.Now; byte[] buffer = ds.GetDataSetSurrogateBytes(); BinaryFormatter ser = new BinaryFormatter(); DataSetSurrogate dss = ser.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate; DataSet dataSet = dss.ConvertToDataSet(); this.label3.Text = string.Format("耗时:{0}", DateTime.Now - dtBegin) + " " + buffer.Length; binddata(dataSet); }