代码如下
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();
}
}
}编译运行,系统不报错,但是要的声音没有,音乐格式也没有错误
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();
}
}
}编译运行,系统不报错,但是要的声音没有,音乐格式也没有错误
SoundPlayer simpleSound = new SoundPlayer(strfulpath);
simpleSound.Load();
simpleSound.Play();