I need to convert byte [] of an image to a format that can be saved in a xml. I tried to convert to a string but not worked. The xml file after 5 images saved was about the size of 50mb! I need to convert to a simpler format for this xml file can not be too heavy.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Consider using a Base64 format - you lose some efficiency but the data will be encapsulated. For example
<image name="MyPhoto.jpg">WFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm</image>
You can convert to Base64 using Convert.ToBase64
回答2:
Try compressing the byte array and hope the size will be smaller :). For example check :DeflateStream and hope the size will be reduced :)