I need to search on all folders and subfolders to find image files. My problem is that I can not search on a network dir and with this code, it only find onde folder and not all folders and subfolders. Any help? Thank you. What I have:
private void Worker_DoWork(object sender, DoWorkEventArgs e)
{
List<string> filesList = new List<string>();
// Create the new DataTable to be used
tableWithPhotos = new DataTable();
tableWithPhotos.Columns.Add("Nome e formato do ficheiro (duplo clique para visualizar a imagem)");
tableWithPhotos.Columns.Add("Caminho ( pode ser copiado Ctrl+C )");
var diretorios = new List<string>() {@"C:\Users\myfolder\pictures"};
var extensoes = new List<string>() { "*.jpg", "*.bmp", "*.png", "*.tiff", "*.gif" };
foreach (string entryExtensions in extensoes)
{
foreach (string entryDirectory in diretorios)
{
filesList.AddRange(Directory.GetFiles(entryDirectory, entryExtensions, SearchOption.TopDirectoryOnly));
}
}