读不出来数据序列化,以经在本地某个目录下生成一个文件了
Formbg fb = new Formbg();
fb.FormText = "aaabbbcc";
using (FileStream fs = new FileStream(strPath, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, fb);
}反序列化 读不出来数据 winform.FormSerial myform = new winform.FormSerial();//当前窗体对象 using (FileStream fs = new FileStream(strPath, FileMode.Open))
{
BinaryFormatter bf = new BinaryFormatter(); Formbg fb = bf.Deserialize(fs) as Formbg; myform.Text = fb.FormText;//设置窗体标题 }
Formbg fb = new Formbg();
fb.FormText = "aaabbbcc";
using (FileStream fs = new FileStream(strPath, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, fb);
}反序列化 读不出来数据 winform.FormSerial myform = new winform.FormSerial();//当前窗体对象 using (FileStream fs = new FileStream(strPath, FileMode.Open))
{
BinaryFormatter bf = new BinaryFormatter(); Formbg fb = bf.Deserialize(fs) as Formbg; myform.Text = fb.FormText;//设置窗体标题 }
解决方案 »
- 调用WSDL生成的webservice代理类报错 [(407) Proxy Authentication Required]
- 如何获取被展开或合拢的TreeNode控件?
- 关于对象序列化的一个问题,急..
- vs2003转VS2005 OpenFileDialog的问题
- 如何将用户输入的数字,转换为int型
- 如何连接远端服务器的oracle数据库?急,在线等!
- 循环生成多个excel问题??????
- 新手求助,望大家帮忙,谢谢
- 怎么使用FolderBrowserDialog
- 急~急~急~~~wpf lync开发里面如何展开TreeView 里面的子节点展开
- WinForm当中,picturebox加载图片如何优化?
- 百度关键字用csharp怎么解析呢,asp很容易做到,charp却不太清楚,请高手赐教。
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;namespace winform
{
[Serializable]
public class Formbg
{
private string strText;
public Formbg()
{
} public string FormText
{
get { return strText; }
set { strText = value; }
} }
}
本文用比较简短的文字讲述了在.net中序列化化对象的三种方式,然后讲述各种方式之间的区别以及在序列化对象时要注意的一些事项。
打开窗体 FormSerial fs = new FormSerial();
fs.MdiParent = this;
fs.Show();然后 在当前窗体上操作myform.Text = "test";为什么当前窗体的也是显示空白的,是不是设置窗体标题不是text属性