Mega Code Archive
Get a list of files from a folder based on the result of a FolderBrowserDialog
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text.RegularExpressions;
public class Utils
{
public static List GetFilesFromFolder(bool bSubDirs)
{
FolderBrowserDialog dlgFolder = new FolderBrowserDialog();
dlgFolder.SelectedPath = "";
if (dlgFolder.ShowDialog() == DialogResult.Cancel)
return new List();
string sDir = dlgFolder.SelectedPath;
string[] sFileList;
if (bSubDirs)
sFileList = Directory.GetFiles(sDir, "*.*", SearchOption.AllDirectories);
else
sFileList = Directory.GetFiles(sDir);
return new List(sFileList);
}
}