Sample code for 30+ languages & platforms
VB.NET

Base64 Encode a File

_LANGUAGE_ to Base64 encode the contents of a file.

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

' Get the contents of a file into a base64 encoded string:
Dim fac As New Chilkat.FileAccess
Dim strBase64 As String = fac.ReadBinaryToEncoded("c:/data/something.pdf","base64")
If (fac.LastMethodSuccess <> True) Then
    Debug.WriteLine(fac.LastErrorText)
    Exit Sub
End If


' Now write the string to a file:
success = fac.WriteEntireTextFile("c:/data/something_pdf_base64.txt",strBase64,"us-ascii",False)
If (success <> True) Then
    Debug.WriteLine(fac.LastErrorText)
    Exit Sub
End If


Debug.WriteLine("Success!")