Hello guys. I have an recursion function which opens me all directories from the path parameter, and gets all .pdf files. Instead of printing each file to the Console, I want to add it to a List<string> which is one of the function parameters.
private static void GetAllFilesFrom(string path, string extension)
{
try
{
if ((File.GetAttributes(path) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
{
foreach (string folder in Directory.GetDirectories(path))
{
foreach (string file in Directory.GetFiles(folder, extension))
{
Console.WriteLine(file);
}
GetAllFilesFrom(folder, extension);
}
}
}
catch (UnauthorizedAccessException) { }
}