Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinForm control to list files in a directory

Tags:

.net

winforms

I'm new to the WinForms control toolbox, so I'm looking to get suggestions on which control I should use for the following simple situation:

I want to have an area on my form that shows a list of the files in a particular directory.

My first quick and dirty inclination is to put a textbox on the form and populate it line-by-line using Directory.GetFiles() - but I know there has to be a more appropriate control. Maybe gridview?

(.NET 3.5)

like image 784
fieldingmellish Avatar asked Oct 17 '25 13:10

fieldingmellish


1 Answers

ListView would be the preferred control. That way you can click on each file name individually, for highlighting/copying, etc

You would also be able to have multiple columns in detail view, and set up sorting on file size, date created, type, etc.

Another advantage of ListView is that you can select multiple items. I use this to delete or open a group of files instead of just one at a time, very handy.

like image 129
Neil N Avatar answered Oct 20 '25 07:10

Neil N



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!