Click to See Complete Forum and Search --> : [RESOLVED] DirectoryInfo.GetFiles trouble


tristan202
September 24th, 2009, 03:31 PM
I have a problem with a piece of code. It is supposed to add all .mp3 files in a specific folder, but I can't get it to work. It doesn't list anything. If I remove the "*.mp3" it works fine, and lists everything.

private void browse_files_Click(object sender, EventArgs e)
{
folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer;
folderBrowserDialog1.ShowNewFolderButton = false;
DialogResult result = this.folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
listbox_files.Items.Clear();
string foldername_files = folderBrowserDialog1.SelectedPath;
selected_path_files.Text = foldername_files;
DirectoryInfo fileListing = new DirectoryInfo(foldername_files);
foreach (FileInfo file in fileListing.GetFiles("*.mp3", SearchOption.AllDirectories))
{
listbox_files.Items.Add(fileListing.ToString() + file.Name);
}

}

}

If possible I would also like it to include .flac and .wma

Thanks in advance from a complet n00b.