using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
System.Text.Encoding encode = System.Text.Encoding.ASCII;
FileStream fileStreamObj;
FileInfo fileInfoObj = new FileInfo(@"H:\New folder (7)\ConsoleApplication1\ConsoleApplication2\test.mp3");
fileStreamObj = fileInfoObj.OpenRead();//.OpenWrite();
byte[] bytedata = new byte[fileInfoObj.Length];
fileStreamObj.Read(bytedata, 0, bytedata.Length);
fileStreamObj.Flush();
fileStreamObj.Close();
string audioBase64Result = Convert.ToBase64String(bytedata, 0, bytedata.Length);
byte[] audioByteArray = Convert.FromBase64String(audioBase64Result);
//fileStreamObj.Write(audioByteArray, 0, audioByteArray.Length);
//MemoryStream ms = new MemoryStream(audioByteArray);
var mp3File = File.Create(@"H:\New folder (7)\ConsoleApplication1\ConsoleApplication2\testResult.mp3", audioByteArray.Length);
mp3File.Write(audioByteArray, 0, audioByteArray.Length);
mp3File.Flush();
mp3File.Close();
}
}
}
把mp3文件编码为base64, 然后再把base64为转换为mp3
最新推荐文章于 2024-08-28 16:59:46 发布