C#窗体播放背景音乐的代码报错!
灵族灵羽 2013-12-31 04:33:54 ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("背景",Application.StartupPath,null);//资源文件不带拓展名称
MessageBox.Show(Application.StartupPath);
byte[] buffer = (byte[])rm.GetObject("背景.mp3");
FileStream fs = new FileStream("背景.mp3",FileMode.Create);//新建文件
BinaryWriter BWriter=new BinaryWriter(fs);//以二进制打开文件流
BWriter.Write(buffer,0,buffer.Length);//从资源文件读取声音文件内容,写入到一个声音文件中
BWriter.Close();
fs.Close();
simpleSound = new SoundPlayer("背景.mp3");
simpleSound.Play();
报错:未能在磁盘上找到任何适合于指定的区域性(或非特定区域性)的资源。
baseName: 背景 locationInfo: <null> fileName: 背景.resources