读不出来数据序列化,以经在本地某个目录下生成一个文件了
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;//设置窗体标题 }
解决方案 »
- 进程间 SendMessage 字节数组 通信 问题
- 后台数据在控件上绑定传参问题
- 关于事务
- form上有一个picturebox控件,picturebox.image为一透明的png图片,我将winform设为透明,运行png图片显得模糊了,有锯齿。这问题怎么解决
- 3des加密算法的问题,急
- Visual Studio2010里linklable用不了了怎么回事?急!
- 新人求助帖,关于窗体中MediaPlayer的
- 誰來幫忙搞定一下或給點提示﹐剛結觸c#不久。。。。在線。。
- 在C#中如何创建WORD文档?
- c#中编码 usc2转ansi
- 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属性