日期:2014-05-18 浏览次数:21264 次
// 创建一个要传输的对象
Account account = new Account(name, birthdate);
FileStream fileStream = new FileStream("temp.dat", FileMode.Create); // 这是抄网上的
BinaryFormatter b = new BinaryFormatter();
b.Serialize(fileStream, account);
fileStream.Close();
// 然后我再读取这个文件,获取该对象
fileStream = new FileStream("temp.dat", FileMode.Open, FileAccess.Read, FileShare.Read);
int data = fileStream.ReadByte();
// 后面的代码就是将data发给客户端。成功