0

How can I list directories & files in a directory and look in those files in the directories found and so on. and check for files like Stackoverflow.exe or "*.exe"

Attempt:

            string[] dirs = Directory.GetDirectories(rootdir);
        string[] Drs = Directory.GetDirectories(dirs.ToString());
        string[] filesp2 = Directory.GetFiles(dirs.ToString());
        Console.WriteLine(String.Join(Environment.NewLine, dirs));
        Console.WriteLine(String.Join(Environment.NewLine, Drs));
        Console.WriteLine(String.Join(Environment.NewLine, filesp2));

Is there a answer to this question? -HoverNot

HoverNot
  • 27
  • 5
  • 1
    As a programmer, have you ever written any recursive code? Same principle - use recursion. – TomTom Nov 02 '21 at 21:58
  • You can use the overload of [`Directory.GetFiles`](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?view=net-5.0#System_IO_Directory_GetFiles_System_String_System_String_System_IO_SearchOption_) that takes a path, search pattern, and search options to specify you want to search recursively `Directroy.GetFiles(path, "*.exe", SearchOption.AllDirectories)` – juharr Nov 03 '21 at 14:14

0 Answers0