I want to ask a user to specify a folder path using a method and save this in the array, then allow that array to be used later on. The problem I have is defining a return type. How should I structure the method?
internal void selectFolderTxt(out string [] files)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.RootFolder = Environment.SpecialFolder.MyComputer;//This causes the folder to begin at the root folder or your documents
if (fbd.ShowDialog() == DialogResult.OK)
{
string[] files = Directory.GetFiles(fbd.SelectedPath, "*.txt", SearchOption.AllDirectories);//change this to specify file type
}
else
{
// prevents crash
}
}
P.S. I Only just started learning to use methods.