i want to make an application, where user can upload their images and display it in Image control without physically saving it in a folder on disk. after done build the cone, an error show on this line.

Dim base64String As String = Convert.ToBase64String(bytes, 0, bytes.Length)

Error show on the attachment below.
7.PNG

Here my full code :

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fs As System.IO.Stream = FileUpload1.PostedFile.InputStream
        Dim br As New System.IO.BinaryReader(fs)
        Dim bytes As Byte = br.ReadBytes(CType(fs.Length, Integer))
        Dim base64String As String = Convert.ToBase64String(bytes, 0, bytes.Length)

        Image1.ImageUrl = "data:image/png;based64," & base64string
        Image1.Visible = True

    End Sub
End Class

Can anyone help me to solve this problem?

Hi DaveAmour :)

Sorry for my late respond. Yes, your solution works!
I need to change the declaration.

Anyway, thank you for helping me ! :)

This question has already been answered. Start a new discussion instead.