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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.