c# 图片XML序列化与反序列化
var xmlDoc = new XmlDocument(); xmlDoc.Load(@"C:\Users\*\Desktop\*.xml"); var node = xmlDoc.SelectNodes("root/block")[0].ChildNodes[3]; var cdata = node.FirstChild as XmlCDataSection; var strImage = cdata.Value; var ms = new MemoryStream(System.Convert.FromBase64String(strImage)); Image returnImage = Image.FromStream(ms); pictureBox1.Image = returnImage;
Image myImage = xxxxx;
System.IO.MemoryStream ms = new System.IO.MemoryStream(); myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); result = System.Convert.ToBase64String(ms.ToArray()); var itemNode = xmlDoc.CreateNode(XmlNodeType.Element, "MyImage", null); itemNode.AppendChild(xmlDoc.CreateCDataSection(result));
桂棹兮兰桨,击空明兮溯流光。