-1
我試着用C#,使媒體播放器,我有一個問題,當我要玩下一首歌曲指數數組的邊界之外的axWindowsMediaPlayer1
「索引數組的範圍之外。」
private void button2_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
files = openFileDialog.SafeFileNames;
path = openFileDialog.FileNames;
for (int i = 0; i < files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
wmp.URL = path[listBox1.SelectedIndex];
}
錯誤"Index was outside the bounds of the array."
發生在
wmp.URL = path[listBox1.SelectedIndex];