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();