List files using CheckBoxes (C # / WinForms)
5 answers
Drop a CheckedListBox into the form, then fill that content using the DirectoryInfo and FileSystemInfo classes, for example:
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("c:\\");
System.IO.FileSystemInfo[] files = di.GetFileSystemInfos();
checkedListBox1.Items.AddRange(files);
+6
source to share
You can use the checklist control that is built into the winforms control (see links below):
http://www.functionx.com/vcsharp/controls/checkedlistbox1.htm
+2
source to share
You can also use the OpenFileDialog class. This will display the standard Windows file open dialog and you can configure it to select multiple files.
In many cases, using the standard dialog can be easier for the user than using the user interface.
Try something like this:
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory =@"C:\temp\";
fileDialog.Multiselect = true;
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string[] files = fileDialog.FileNames;
}
Or you can add a dialog to the form constructor and set its properties there.
+1
source to share