//You have a byte[] representing some binary information, such as a bitmap.
// You need to encode this data into a string so that it can be sent over
// a binary-unfriendly transport, such as email.
public string Base64EncodeBytes(byte[] inputBytes)
{
return (Convert.ToBase64String(inputBytes));
}
//You have a String that containsinformation such asa bitmap encoded
// asbas e64. You need to decode this data (which may have been embedded in an
// email message) from a String into a byte[] so that you can access
// the original binary.
public byte[] Base64DecodeString(string inputStr)
{
byte[] decodedByteArray = Convert.FromBase64String(inputStr);
return (decodedByteArray);
}
منبع : "C# 3.0 Cookbook™, Third Edition"