Hi, I just finished making a program which displays all the files in a directory and lets me open them when selected. What I find is that I get every file found in the directory however not divided by sub-directory, is there a way i can do this showing it on the listbox?
Heres my code so far.
List<FileInfo> myBooks = new List<FileInfo>();
void fileInfoDelegate()
{
myBooks.Sort(
delegate(FileInfo a, FileInfo b)
{
return a.Name.CompareTo(b.Name);
});
}
//VideoTraining
private void button8_Click(object sender, EventArgs e)
{
clear(); // clear lstbox b4 repopulate.
myBooks.AddRange(new DirectoryInfo(@"C:VideoTraining\").GetFiles("*.*", SearchOption.AllDirectories));
fileInfoDelegate();
listBox1.DataSource = myBooks;
boxempty(); // returns msg if lstbox is empty
}
//OpenFile
private void button13_Click(object sender, EventArgs e)
{
FileInfo TempInfo = myBooks[listBox1.SelectedIndex];
System.Diagnostics.Process.Start(TempInfo.FullName);
}
Thanks Guys.