c#序列化 图片 求助
public void Serializable(){
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
saveFileDialog1.Filter = "xml文件(*.xml)|*.xml";
string name = saveFileDialog1.FileName;
byte[] value = File.ReadAllBytes(openFileDialog1.FileName);
Serializable s = new Serializable(name,value)//序列化
{
Name = saveFileDialog1.FileName,
Value = File.ReadAllBytes(saveFileDialog1.FileName)
};
XmlSerializer ser = new XmlSerializer(typeof(Serializable));
FileStream fs =new FileStream(saveFileDialog1.FileName,FileMode.Create);
ser.Serialize(fs, s);
fs.Close();
}
}
public void DeSerializable()
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
XmlSerializer ser = new XmlSerializer(typeof(Serializable));
Serializable s = (Serializable)ser.Deserialize(new FileStream(openFileDialog1.FileName, FileMode.Open));
//FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open);
this.pictureBox1.Image = Image.FromStream(new MemoryStream(s.Value));
}
}
序列化可以把值写进去,反序列怎么不能打开 求大侠帮帮。。。或者有新的方法也可以说下 谢谢