路径不是法律形式错误c#

时间:2014-10-12 21:53:41

标签: c#

我正在尝试通过Form1_Load上的AudioHandler()设置Menu_Track路径,但它没有添加到Menu_Track的路径。 mts mts mts mts

namespace NGTurnBased
{
class MyVariables
{

    public static string Menu_Track;
    public static SoundPlayer AudioPlayer = new SoundPlayer(Menu_Track);
    public static int Essence = 0;


}
}

 private void Form1_Load(object sender, EventArgs e)
    {

        rdb_Ryu.Click += Character_Selected;
        rdb_momiji.Click += Character_Selected;
        getForm();
        AudioHandler();


    }
   private void AudioHandler()
    {
        if (currentForm != "test")
        {
            MyVariables.Menu_Track = @"C:\Users\Gary\Desktop\NGRPG\Volf_BGM.wav";
        }
        MyVariables.AudioPlayer.Play();

    }

1 个答案:

答案 0 :(得分:0)

public static string Menu_Track;
public static SoundPlayer MenuSelection = new SoundPlayer(Menu_Track);

在这里你应该指定SoundPlayer的路径。在momemnt你有新的SoundPlayer(null) - >这不是wav文件的有效路径。

编辑: 感谢评论@ThomasLevesque