Public Function ConvertFileToBase64(ByVal fileName As String) As String
Dim ReturnValue As String = ""
If My.Computer.FileSystem.FileExists(fileName) Then
Using BinaryFile As FileStream = New FileStream(fileName, FileMode.Open)
Dim BinRead As BinaryReader = New BinaryReader(BinaryFile)
Dim BinBytes As Byte() = BinRead.ReadBytes(CInt(BinaryFile.Length))
ReturnValue = Convert.ToBase64String(BinBytes)
BinaryFile.Close()
End Using
End If
Return ReturnValue
End Function
The questions I want to ask:
Public Function ConvertFileToBase64(ByVal fileName As String) As String
Return Convert.ToBase64String(System.IO.File.ReadAllBytes(fileName))
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With