简体   繁体   English

如何使用C#通过XML发送图像

[英]How to send image through XML using C#

I have a image that I need to embed in XML and then retrieve the image using C#. 我有一个图像,我需要嵌入XML,然后使用C#检索图像。 How can I do this? 我怎样才能做到这一点?

Convert it to a byte[] and convert this to a Base64 datablock (using Convert.ToBase64String() ), which you put into the xml. 将它转换为byte[]并将其转换为Base64数据块(使用Convert.ToBase64String() ),将其放入xml中。 On the other side, you simply have to decode it with Convert.FromBase64String() and deal with the resulting byte[] the way you like. 另一方面,您只需使用Convert.FromBase64String()对其进行解码,并按照您喜欢的方式处理生成的byte[]

Either you have to include binary data in XML tags; 您必须在XML标记中包含二进制数据; or you need to put the image somewhere else and send the link with your XML 或者您需要将图像放在其他位置并使用XML发送链接

you can convert your image into base64 data and write in xml ! 你可以将你的图像转换为base64数据并写入xml!

help: 救命:

code snippet 代码段

stackoverflow discussion stackoverflow讨论

embed image in xml? 在xml中嵌入图像? You mean putting image in a xml document? 你的意思是将图像放在xml文档中?

See the link http://www.codeproject.com/KB/cs/lookchanger.aspx 访问http://www.codeproject.com/KB/cs/lookchanger.aspx链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM