编辑器加载中...
//Image写入XML
using System.IO;
using System.Runtime.Serialization.Formatters.Soap;
string MyFile = @"D:\数据处理\image.xml";
string imageFile = @"G:\zengwei.jpg";
Stream MyStream;
SoapFormatter MyFormatter =new SoapFormatter();
void Mathod1()
{
try
{
MyStream = new FileStream(
MyFile,
FileMode.Create,
FileAccess.Write,
FileShare.None);
MyFormatter.Serialize(
MyStream, pictureBox1.Image);
MyStream.Close();
MessageBox.Show("完成!");
}
catch (Exception ex)
{
}
}
//读取XML显示IMAGE
void Mathod2(){
try
{
MyStream = new FileStream(
MyFile,
FileMode.Open,
FileAccess.Read,
FileShare.None);
pictureBox1.Image =
(Bitmap)MyFormatter.Deserialize(MyStream);
MyStream.Close();
}
catch (Exception ex)
{ }
}
void Mathod3()
{
pictureBox1.Image = Image.FromFile(imageFile);
}