2013-08-18 147 views
0

我试图找到一种方法来存储文本文件中的MP3音频。我的计划是将原始的mp3文件转换为base64字符串,然后保存。VB.NET - 将MP3转换为Base64字符串

我花了很多时间询问Google,但只能找到一种方法将base64字符串转换回mp3。

这甚至可能吗?我也开放其他解决方案,我只需要能够将文件转换为文本,然后回到MP3格式。我使用的是Visual Basic .NET,但我认为C#也可以帮助我。

回答

2

使用Convert.ToBase64String method字节数组转换成一个base64字符串:

' load file into a byte array 
Dim data As Byte() = File.ReadAllBytes(filename) 
' convert the byte array to base64 
Dim str As String = Convert.ToBase64String(data) 
' write the string to a file 
File.WriteAllText(newFilename, str)