如何序列化->压缩->加密 一个datatable 然后 解密->解压缩->反序列化?如分不够再开新贴送
谢谢了!--------------------编程问答--------------------
--------------------编程问答-------------------- 序列化:
/// <summary>
/// 序列化
/// </summary>
/// <param name="dsOriginal"></param>
/// <returns></returns>
static public byte[] GetBinaryFormatData(DataSet dsOriginal)
{
byte[] binaryDataResult = null;
MemoryStream memStream = new MemoryStream();
IFormatter brFormatter = new BinaryFormatter();
dsOriginal.RemotingFormat = SerializationFormat.Binary;
brFormatter.Serialize(memStream, dsOriginal);
binaryDataResult = memStream.ToArray();
memStream.Close();
memStream.Dispose();
return binaryDataResult;
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="binaryData"></param>
/// <returns></returns>
static public DataSet RetrieveDataSet(byte[] binaryData)
{
DataSet dataSetResult = null;
try
{
MemoryStream memStream = new MemoryStream(binaryData);
IFormatter brFormatter = new BinaryFormatter();
object obj = brFormatter.Deserialize(memStream);
dataSetResult = (DataSet)obj;
//return dataSetResult;
}
catch { }
return dataSetResult;
}
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream memStream = new MemoryStream();
formatter.Serialize(memStream, datatable);
压缩用SharpZipLib
加密用DES. --------------------编程问答-------------------- 序列化成byte[]之后你可以在网上找下压缩的方法,或者加密的方法。。。。 --------------------编程问答-------------------- 学习 --------------------编程问答-------------------- Mark
--------------------编程问答--------------------
如果要压缩的是文件夹的话,自己要用递归处理下 --------------------编程问答-------------------- 也可以用Soap或XML序列化 --------------------编程问答-------------------- ...有没有代码? 要完整的.
补充:.NET技术 , C#