In fact, it is very simple. to convert an image file to base64string, you only need a tobase64string method in the convert class.
Image fromimage = image. fromfile (txtimg. Text );
Memorystream stream = new memorystream ();
Fromimage. Save (stream, imgformat [extension]);
Txtstring. Text = convert. tobase64string (stream. getbuffer ());
It seems that the icon file cannot be converted (the result of your own test). If you need to convert the icon, you have to change it. The curve saves the country ~
To extract an image from base64string, the convert. frombase64string () method is required,
Memorystream stream = new memorystream (convert. frombase64string (txtstring. Text ));
Bitmap IMG = new Bitmap (Stream );
IMG. Save (txtimg. Text );
MessageBox. Show ("completed! ");
It seems that some comrades encountered problems when switching back, and they thought it was a problem when defining stream. When new, they directly gave the converted byte [] to it, there should be no "beyond the expected range" error. Conversion Problems should be caused by the fact that the source image is generated in Java or other languages. Because base64 encoding is the same.