2.4. Base64 Encode Binary Data

Problem

You need to convert binary data into a form that can be stored as part of an ASCII text file (such as an XML file) or sent as part of a text e-mail message.

Solution

Use the Shared methods ToBase64CharArray and FromBase64CharArray of the System.Convert class to convert your binary data to and from a Base64-encoded Char array. If you need to work with the encoded data as a string value rather than as a Char array, you can use the ToBase64String and FromBase64String methods of the Convert class instead.

How It Works

Base64 is an encoding scheme that enables you to represent binary data as a series of ASCII characters so that it can be included in text files and e-mail messages in which raw binary data is ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.