串行化是什么意思啊
// 串行化对象。public BinaryFormatter f;
// 串行化对象输出。
private void button1_Click(object sender, System.EventArgs e)
{
if(pictureBox1.Image != null)
{
saveFileDialog1.Filter = "自定义文件(*.ser)|*.ser";
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
s = File.Create(saveFileDialog1.FileName);
f = new BinaryFormatter();
// 存储图形文件和对应的文件名。
f.Serialize(s, pictureBox1.Image);
f.Serialize(s, textBox1.Text);
s.Close();
}
}
}
// 对象输入。
private void button2_Click(object sender, System.EventArgs e)
{
openFileDialog1.Filter = "自定义文件(*.ser)|*.ser";
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
s = File.OpenRead(openFileDialog1.FileName);
f = new BinaryFormatter();
pictureBox1.Image = (Image)f.Deserialize(s);
textBox1.Text = (string)f.Deserialize(s);
s.Close();
}
}