C# 求WINCE实现对象序列化BinaryFormatter的方法,有没办法在CE下把类写成一个文件?
下面代码中在WIN7下通过 但是转到智能平台开发 CE的下面 就没有BinaryFormatter的方法
Student objStu = new Student()
{
Name = this.txtName.Text.Trim(),
Age = Convert.ToInt16(this.txtAge.Text.Trim()),
Gender = this.txtGender.Text.Trim(),
Birthday = Convert.ToDateTime(this.txtBirthday.Text.Trim())
};
//【1】创建文件流
FileStream fs = new FileStream("C:\\objStu.obj", FileMode.Create);
//【2】创建二进制格式化器
BinaryFormatter formatter = new BinaryFormatter();
//【3】调用序列化方法
formatter.Serialize(fs, objStu);
//【4】关闭文件流
fs.Close();
不过google code被gfvv了,,需要跨越下才能看见,你懂的。
参考:http://stackoverflow.com/questions/5091712/binaryformatter-does-not-exist-in-cf-solutions
使用protobuf-net代替
google能找到。别告诉我你用的某国内山寨搜索引擎,那东西不收录英文内容的,连msdn都收不全。