将 byte[] 写入 mp3 文件

问题描述 投票:0回答:1

这就是我正在做的事情,我读取了一个

.mp3
文件,然后将其转换为
Base64String
这样:

using (fileStream)
{ 
  fileStreamLength = (int)fileStream.Length + 1;
  fileInBytes = new byte[fileStreamLength];
  int currbyte = 0, i = 0;
  while (currbyte != -1)
  {
  currbyte = fileStream.ReadByte();
  fileInBytes[i++] = (byte)currbyte;
  }
}
    
string fileInString = Convert.ToBase64String(fileInBytes);

现在,经过一些工作,我再次拥有相同的

Base64String
,我将通过
byte[] asBytesAgain = Convert.FromBase64String(fileInString);

将其转换为字节

现在我的问题是如何将这个

byte[]
编写为要播放的
.mp3
文件?

c# .net mp3
1个回答
8
投票
File.WriteAllBytes("somefile.mp3", asBytesAgain);
© www.soinside.com 2019 - 2024. All rights reserved.