0

我正在尝试找到一种将 mp3 声音存储在文本文件中的方法。我的计划是将原始 mp3 文件转换为 base64 字符串,然后保存。

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

这甚至可能吗?我也愿意接受其他解决方案,我只需要能够将文件转换为文本,然后再转换回 mp3 格式。我正在使用 Visual Basic .NET,但我认为 C# 也可以帮助我。

4

1 回答 1

2

使用Convert.ToBase64String方法将字节数组转换为 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)
于 2013-08-18T19:58:30.173 回答