0

Image files are saved in base64 string format in the database. I'm trying to load the image using DocuVieware via MemoryStream but failed.

Does anyone tried this kind of approach?

        if (this.IsPostBack != true)
        {
            var file = new DataFileManager().GetImageByID(userID);
            byte[] byt = System.Text.Encoding.UTF8.GetBytes(file.CurrentImage);
            DocuVieware1.LoadFromStream(new MemoryStream(byt, 0, byt.Length), true);
        }

1 Answer 1

1

You probably need to replace:

byte[] byt = System.Text.Encoding.UTF8.GetBytes(file.CurrentImage);

by:

byte[] data = Convert.FromBase64String(file.CurrentImage);

Ref: https://learn.microsoft.com/en-us/dotnet/api/system.convert.frombase64string?view=netframework-4.8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.