| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
afm_dw
10年前发布

c#使用System.Media.SoundPlayer播放资源文件中的wav文件

c#使用System.Media.SoundPlayer播放资源文件中的wav文件

using System.Reflection;  using System.IO;  using System.Resources;  using System.Media;  using System.Diagnostics;    namespace CN.OutOfMemory.Csharp  {      public partial class Form1 : Form      {          public Form1()          {              InitializeComponent();          }            private void Form1_Load(object sender, EventArgs e)          {                Assembly assembly;              Stream soundStream;              SoundPlayer sp;              assembly = Assembly.GetExecutingAssembly();              sp = new SoundPlayer(assembly.GetManifestResourceStream("Yournamespace.Dreamer.wav"));              sp.Play();             }        }  }    /*SoundPlayer sp = new SoundPlayer(global::WindowsApplication1.Properties.Resources.yoursoundfilename); */