private void button1_Click(object sender, EventArgs e)
{ String c="工期"; Stream stream = File.Open("EmployeeInfo.osl", FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); Console.WriteLine("序列化"); bformatter.Serialize(stream, c); stream.Close(); //反序列化 String s; Stream fs = File.OpenRead("EmployeeInfo.osl"); BinaryFormatter deserializer = new BinaryFormatter(); s = (String)(deserializer.Deserialize(fs));//反序列化得到的对象 fs.Close(); Console.WriteLine("s="+s);}
本文转自94cool博客园博客,原文链接http://www.cnblogs.com/94cool/archive/2010/02/21/1670536.html,如需转载请自行联系原作者