前提:
需要备份的数据由接口 object转换成byte[],备份保存到本地文件;
选择本地文件,取得数据 byte[]转换成object,用于数据恢复。
步骤如下:
1.把对象(数据)list ( object ) 序列化并返回相应的字节byte[]
public byte[] SerializeObject(object pObj)
{
byte[] listRead = null;
try
{
if (pObj == null)
return null;
System.IO.MemoryStream _memory = new System.IO.MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(_memory, pObj);
_memory.Position = 0;
byte[] read = new byte[_memory.Length];
_memory.Read(read, 0, read.Length);
_memory.Close();
byte[] sdata = new byte[read.Length];
Buffer.BlockCopy(read, 0, sdata, 0, read.Length);
listRead =
版权声明:本文为qq_20758141原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。