Sample code for 30+ languages & platforms
C#

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat C# Downloads

C#
bool success = false;

Chilkat.BinData bd = new Chilkat.BinData();

success = bd.LoadFile("qa_data/jpg/starfish.jpg");
if (success == false) {
    Debug.WriteLine("Failed to load file.");
    return;
}

Debug.WriteLine(bd.GetEncoded("base64"));

// If you want mult-line base64:
Debug.WriteLine("--");
Debug.WriteLine(bd.GetEncoded("base64_mime"));

// If you want hex..
Debug.WriteLine("--");
Debug.WriteLine(bd.GetEncoded("hex"));

// etc.