System.ArgumentException: Complex DataBinding accepts as a data source either an IList or an IListSource

Viewed 21457

I'm using the C# code below to populate a WinForms ListBox. I want to hide all System folders however. Like the $RecyclingBin for example. But it gives me the following error.

System.ArgumentException: Complex DataBinding accepts as a data source either an IList or an IListSource.

Being new to LINQ this is more than confusing to me. Can anyone tell me where I'm going wrong?

string[] dirs = Directory.GetDirectories(@"c:\");
var dir = from d in dirs
          where !d.StartsWith("$")
          select d;

listBox.DataSource = (dir.ToString()); 
1 Answers
Related