Base64 to Image Conversion Error

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
i try to convert attached base64 text to image displayed Error " Invalid length for a Base-64 char array." in my Winform Application.
Base64 Text File sample :
https://www.dropbox.com/s/cdqv53kfbu5z2us/base64.txt
Same base64 text can successfully convert to image using below link

http://www.freeformatter.com/base64-encoder.html
i got this Error Message : "Invalid length for a Base-64 char array." from my below function
Public Shared Function Base64ToImage(base64String As String) As Image
Convert Base64 String to byte[]
Dim imageBytes As Byte() = Convert.FromBase64String(base64String)

Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)

Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length)

Dim image__1 As Image = Image.FromStream(ms, True)

Return image__1

End Function


Please "Mark as Answer" if this post answered your question. :)

Kalpesh Chhatrala | Software Developer | Rajkot | India

Kalpesh s Blog

VFP Form to C#, Vb.Net Conversion Utility

View the full article
 
Back
Top