I currently have to code to allow me to read all of the files of a folder and write them to the console. Below, I also have got the code to select individual files from a directory using a browser. I would like to know how I would be able to select a folder using a browse button.
code to check all files
foreach(var path in Directory.GetFiles(@"C:\Name\Folder\"))
{
Console.WriteLine(path); // full path
Console.WriteLine(System.IO.Path.GetFileName(path)); // file name
}
Code to open dialog box
OpenFileDialog fileSelectPopUp = new OpenFileDialog();
fileSelectPopUp.Title = "";
fileSelectPopUp.InitialDirectory = @"c:\";
fileSelectPopUp.Filter = "All EXCEL FILES (*.xlsx*)|*.xlsx*|All files (*.*)|*.*";
fileSelectPopUp.FilterIndex = 2;
fileSelectPopUp.RestoreDirectory = true;
if (fileSelectPopUp.ShowDialog() == DialogResult.OK)
{
textBox1.Text = fileSelectPopUp.FileName;
}