I have this form which includes a combobox, and a listbox. The combobox has each subfolder inside the graphics folder as it's items. When the combobox's selected value changes the program will list every .png file inside the selected folder and add them to the listbox's items.
The problem is that without showing a messagebox in between adding the files to an array, and adding each item to the listbox, the array will stay empty.
Here's the code:
private void graphicBox_SelectedIndexChanged(object sender, EventArgs e)
{
graphicList.Items.Clear();
string selectedfolder = SkinSuite.Properties.Settings.Default.exepath + "\\GRAPHIC\\" + graphicBox.SelectedText;
graphicfiles = Directory.GetFiles(SkinSuite.Properties.Settings.Default.exepath + "\\GRAPHIC\\" + graphicBox.SelectedText);
// MessageBox.Show("FOR SOME REASON THIS DOESNT WORK IF I DONT SHOW YOU A MESSAGEBOX!");
foreach (string file in graphicfiles)
{
graphicList.Items.Add(Path.GetFileName(file));
}
}
If I were to uncomment the messagebox line, the code works just fine.