When I click the button the first time, it works, but after that, it doesn't do anything. I have tried to debug this and I have looked it up but I can't find an answer. I am probably just not noticing something obvious.
private void button5_Click(object sender, EventArgs e)
files = Directory.GetFiles("Tasks");
foreach (string file in files)
StreamReader reader = new StreamReader(file);
lines = File.ReadAllLines(file);
listBox1.DataSource = tasks;
You're problem is not with the button. It's with the listbox. It's not updating properly because it's not detecting a change in your datasource.
Try setting it to null before updating so it knows it's changing:
listBox1.DataSource = null; listBox1.DataSource = tasks;
You can also use a BindingList instead of a regular list.