這個工程,當我只是調用函數和播放文件,但是如果我想從文件夾中選擇隨機播放它停止說「索引超出了數組的界限」。播放隨機mp3文件未知錯誤
任何人都可以發現什麼是錯的?
public void playrandomsound()
{
if (mp3 != null)
{
mp3.Dispose();
}
var files = new DirectoryInfo(Application.StartupPath).GetFiles(".mp3");
int index = new Random().Next(0, files.Length);
string filename = files[index].Name.ToString(); <-- App stops here
string tune = string.Concat(Application.StartupPath, "//", fiilename);
mp3 = new Audio(tune);
mp3.Play();
}
如果我刪除錯誤行上的「tostring」方法,它仍會給出相同的錯誤。
你在使用什麼音頻庫? – ohmusama 2011-04-25 20:29:36