C# – How to customize OpenFileDialog to select multiple folders and files?

If you use the FileNames property instead of the FileName property, you get a string array of each file selected, you select multiple files using the shift key. Like so: private void button1_Click(object sender, EventArgs e) { OpenFileDialog x = new OpenFileDialog(); x.Multiselect = true; x.ShowDialog(); string[] result = x.FileNames; foreach (string y in result) … Read more

OpenFileDialog can’t load CSV files but can load xls/xlsx Excel files [duplicate]

About the reported error: System.NullReferenceException: Object reference not set to an instance of an object. sConnectionString was null. The exception is generated because the Connection string is declared as: public string sConnectionString; Since it’s never initialized, because the initialization of the Connection string is performed only for some file types but not all those included … Read more

Customizing OpenFileDialog

Yes, that’s possible, I did the same kind of customization with SaveFileDialog successfully and it’s pretty interesting. Follow the following links: http://www.codeproject.com/KB/dialog/OpenFileDialogEx.aspx http://www.codeproject.com/KB/cs/getsavefilename.aspx http://www.codeproject.com/KB/dialog/CustomizeFileDialog.aspx Also my own questions too will help you: Change default arrangement of Save and Cancel buttons in SaveFileDialog How to stop overwriteprompt when creating SaveFileDialog using GetSaveFileName You have to use … Read more

Select either a file or folder from the same dialog in .NET

Technically, it is possible. The shell dialog used by FolderBrowseDialog has the ability to return both files and folders. Unfortunately, that capability isn’t exposed in .NET. Not even reflection can poke the required option flag. To make it work, you’d have to P/Invoke SHBrowseForFolder() with the BIF_BROWSEINCLUDEFILES flag turned on in BROWSEINFO.ulFlags (value = 0x4000). … Read more