wa22guy Posted October 24, 2004 Share Posted October 24, 2004 I want to scan a local folder, find all .txt files in that folder, fill a collection/datasource with it, and then fill a ListBox. Anyone have some quick sample code? Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted October 24, 2004 Share Posted October 24, 2004 I want to scan a local folder, find all .txt files in that folder, fill a collection/datasource with it, and then fill a ListBox. Anyone have some quick sample code? 584799419[/snapback] string[] files = Directory.GetFiles(Environment.CurrentDirectory, "*.txt"); ArrayList _files = new ArrayList(files); listBox1.Items.AddRange(files); Link to comment Share on other sites More sharing options...
0 wa22guy Posted October 25, 2004 Author Share Posted October 25, 2004 ? string[] files = Directory.GetFiles(Environment.CurrentDirectory, "*.txt"); ? ArrayList _files = new ArrayList(files); ? listBox1.Items.AddRange(files); 584799983[/snapback] Thanks, that's perfect. It actually worked better like this: string[] fileList = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.txt"); lstFiles.Items.AddRange(fileList); Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted October 25, 2004 Share Posted October 25, 2004 Thanks, that's perfect. It actually worked better like this: string[] fileList = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.txt"); lstFiles.Items.AddRange(fileList); 584800347[/snapback] Um... yeah, I know. I put the ArrayList in there because you said you wanted to store the files in a collection. I know it was redundant, and I know an array is a collection, but I wasn't sure exactly what you're doing, so I erred on the side of too much info. :) Link to comment Share on other sites More sharing options...
Question
wa22guy
I want to scan a local folder, find all .txt files in that folder, fill a collection/datasource with it, and then fill a ListBox. Anyone have some quick sample code?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts