Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.NotSupportedException错误_C# - Fatal编程技术网

C# System.NotSupportedException错误

C# System.NotSupportedException错误,c#,C#,我有一个系统。NotsupportedException错误。它表示不支持给定路径的格式。我在游戏中添加音乐时出错。我该怎么做才能摆脱它 SoundPlayer player = new SoundPlayer("@\\mymusic.wav"); player.Play(); 编码时似乎没有错误,但当我运行代码时,它会显示System.NotsupportedExceptionerror。 你能告诉我吗。我做错什么了吗?您的语法不正确 改变 SoundPlayer player = new

我有一个
系统。NotsupportedException
错误。它表示不支持给定路径的格式。我在游戏中添加音乐时出错。我该怎么做才能摆脱它

SoundPlayer player = new SoundPlayer("@\\mymusic.wav");
player.Play();
编码时似乎没有错误,但当我运行代码时,它会显示
System.NotsupportedException
error。
你能告诉我吗。我做错什么了吗?

您的语法不正确

改变

SoundPlayer player = new SoundPlayer("@\\mymusic.wav");
player.Play();
…到


…假设.wav文件与应用程序位于同一驱动器上。

路径格式不正确。如果.wav与exe位于同一文件夹中,只需使用
newsoundplayer(“mymusic.wav”)
什么意思?@\`表示字符串中没有转义字符。在这种情况下,您需要在
前面加上
@
// move @ to front and outside quotes
SoundPlayer player = new SoundPlayer(@"\mymusic.wav"); 
player.Play();