代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void Form1_Load(object sender, EventArgs e)
        {   
            string strfulpath=@"明月几时有.wav"; //获得声音文件的绝对路径
            SoundPlayer simpleSound = new SoundPlayer(strfulpath);
            simpleSound.Play();
        } 
    }
}编译运行,系统不报错,但是要的声音没有,音乐格式也没有错误

解决方案 »

  1.   

    string strfulpath=@"明月几时有.wav"; //获得声音文件的绝对路径你这句也不是个绝对路径啊。。你这是个相对路径
    SoundPlayer simpleSound = new SoundPlayer(strfulpath);
    simpleSound.Load();
      simpleSound.Play();
      

  2.   

    播放声音还有一种方法用 DllImport 引入 Winmm.dll
      

  3.   

    路径正确吗?string path = Environment.Current()+"\\明月几时有.wav";这样才对吧。。