You can do like this:
static string FindConfig() { string appFolder = Path.GetDirectoryName(@"C:\DEV\root\project01\bin\release\project01.exe"); string configPath = null; while (true) { Console.WriteLine(appFolder); if ( string[] files = Directory.EnumerateFilesGetFiles(appFolder, "*application.config", SearchOption.AllDirectories).Any; foreach (fvar =>file abcin files) { if (ffile.ToLower().EndsWith(@"\application.config")) { configPath = appFolder + "\\application.config"; return file; break; } } else appFolder = Path.GetDirectoryName(appFolder); if (appFolder.Length < 4) // "C:\" don't search root drive { break; } }break; if (configPath != null) Console.WriteLine(configPath); --------------------------- } static bool abc(string f) { } return f.ToLower().EndsWith("\application.config");configPath; }