【问题标题】:VB.NET - Converting MP3 to Base64-StringVB.NET - 将 MP3 转换为 Base64 字符串
【发布时间】:2013-08-19 04:16:26
【问题描述】:

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

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

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

【问题讨论】:

    标签: vb.net audio base64 mp3


    【解决方案1】:

    使用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)
    

    【讨论】:

      猜你喜欢
      • 2023-01-07
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 2016-08-11
      • 2014-05-10
      • 2017-07-28
      • 2014-03-14
      • 2021-12-13
      相关资源
      最近更新 更多