如何使用C#将图像插入XML? [英] How could it be possible to insert an image into XML using C#?
本文介绍了如何使用C#将图像插入XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi
我想使用C#将图像添加到带有
Hi I would like to add an image into a xml file with
XmlWriter
的xml文件中。
我该怎么做?
我的尝试:
using C#.
How can I do it?
What I have tried:
Bitmap bmp = new Bitmap(imagePath);
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
XElement img = new XElement("image",
Convert.ToBase64String(
(byte[])converter.ConvertTo(bmp, typeof(byte[]))));
xmlWriter.WriteStartElement("img");
xmlWriter.WriteString(img.ToString());
xmlWriter.WriteEndElement();
推荐答案
阅读:将图像插入XML文件 - Stack Overflow [ ^ ]
这篇关于如何使用C#将图像插入XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文