private void GetFromDirectory(string startDirectory, Action <string> useDir) { FileSelector fs = new FileSelector(startDirectory); Console.WriteLine("Enter the associated number to move into that directory"); Console.WriteLine("Enter ! to select the current directory"); Console.WriteLine("Enter . to go up one level"); Exception ex; string dir = ""; do { string cmd; do { int i = 0; foreach (string s in fs.Directories) { i++; Console.WriteLine(i + " " + s); } cmd = Console.ReadLine(); if (cmd == ".") { fs.MoveUp(); } else if (cmd != "!") { try { fs.MoveInto(fs.Directories.ToArray()[int.Parse(cmd) - 1]); } catch (Exception e) { Console.WriteLine("Invalid command"); } } } while (cmd != "!"); dir = fs.current + "\\"; ex = null; try { useDir(dir); } catch (Exception e) { Console.WriteLine($"{e}\n{dir}"); ex = e; } } while (ex != null); }