2013-08-18 146 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)