积极答复者
在应用. 一.A程序员二进制序列化一个类,保存文件为XX.bin 二.复制XX.bin文件给B程序员. 三.B程序员反序列化这个XX.bin文件.供B调用,怎么做? 注意帮我写段如何调用反序列化后的调用类代码吧!!

问题
答案
-
你好!
可以参考这里的实例,希望对你有帮助:
http://msdn.microsoft.com/zh-cn/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx
周雪峰- 已标记为答案 YiChun Chen 2009年10月7日 5:23
全部回复
-
你好!
可以参考这里的实例,希望对你有帮助:
http://msdn.microsoft.com/zh-cn/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx
周雪峰- 已标记为答案 YiChun Chen 2009年10月7日 5:23
-
你好!
周版主贴出的就是描述关于序列化和反序列化的实例。序列化部分- Serialize() 和反序列化部分- Deserialize()。
有哪些地方是你不明白的呢?
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- 已编辑 YiChun Chen 2009年10月7日 5:26 typo
-
反序列化后,是一个类,如何用这个类呀/?
如:
public static object fnDeSerializFromFile(string v_path)
{
try
{
using (FileStream __fs = System.IO.File.OpenRead(v_path))
{
byte[] byts = new byte[__fs.Length];
__fs.Read(byts, 0, (int)__fs.Length);
BinaryFormatter __bf = new BinaryFormatter();
object result = __bf.Deserialize(__fs);
__fs.Close();
return result;
}
}
catch (Exception ex)
{
My.Msg.ExceptionInfo.ShowExceptionError("fnDeSerializ", ex);
return null;
}
}//从文件转换为对象
如何引用这个对象的成员函数或变量呢??