读书人

如何把byte[]转换成base64的byte[]

发布时间: 2012-01-18 00:23:26 作者: rapoo

怎么把byte[]转换成base64的byte[]?
我用binaryreader读取了一个二进制的内容,怎么把这个二进制的内容换成base64的二进制内容。
public byte[] getBase64(byte[] content)
{
System.Text.ASCIIEncoding asc = new System.Text.ASCIIEncoding();
byte[] b;
string strBase64;

strBase64 = System.Convert.ToBase64String(content);
b = asc.GetBytes(strBase64);

return b;
}

我这么写对吗?好像结果不符合base64。

[解决办法]
b = asc.GetBytes(strBase64);
===
b = Convert.FromBase64String( strBase64 )
[解决办法]
ToBase64Transform

读书人网 >C#

热点推荐