C#下如何读取反序列化后的文件内容并且显示?
RT,做的是WINDOWS应用程序,要将反序列化后的文件内容读取并且显示在文本框里,请问这里的代码要如何写?FileStreamfs=newFileStream("D:\...
RT,做的是WINDOWS应用程序,要将反序列化后的文件内容读取并且显示在文本框里,请问这里的代码要如何写?
FileStream fs = new FileStream("D:\\名片.txt", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
object ob = bf.Deserialize(fs);
fs.Close();
People pe = (People)ob;
textBox5.Text = pe;
编译无法通过,一直提示“无法将类型“电子名片2.Form1.People”隐式转换为“string””,请问这边要怎么修改? 展开
FileStream fs = new FileStream("D:\\名片.txt", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
object ob = bf.Deserialize(fs);
fs.Close();
People pe = (People)ob;
textBox5.Text = pe;
编译无法通过,一直提示“无法将类型“电子名片2.Form1.People”隐式转换为“string””,请问这边要怎么修改? 展开
1个回答
展开全部
protected void btnFXL_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("xlhSj.txt", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
string fxlhContent = bf.Deserialize(fs).ToString();
this.txtXl.Text = fxlhContent;
fs.Close();
}
{
FileStream fs = new FileStream("xlhSj.txt", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
string fxlhContent = bf.Deserialize(fs).ToString();
this.txtXl.Text = fxlhContent;
fs.Close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询