我正在制作媒体播放器,目前它只能找到mp3文件。我现在想要增加它可以找到的文件类型,例如wavs,aacs等。我怎样才能做到这一点?
这是我目前的代码:
private void button2_Click(object sender, EventArgs e)
{
string musicPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
folderBrowserDialog1.SelectedPath = musicPath;
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(folderBrowserDialog1.SelectedPath);
System.IO.FileInfo[] Files = dinfo.GetFiles("*.mp3"); //This is the line I am checking for files with a certain extension.
MusicBox.Items.Clear();
foreach (System.IO.FileInfo file in Files)
{
MusicBox.Items.Add(file.FullName);
}
}
}
}