FastReport
34 строки · 969.0 Байт
1using System.IO;
2using System.Reflection;
3
4namespace ConsoleAppsUtils
5{
6public static class Utils
7{
8private static string GetDirectory(string subPath)
9{
10if (subPath == null)
11return Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
12return Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), subPath);
13}
14
15public static string FindDirectory(string directory1)
16{
17string thisFolder = GetDirectory(null);
18try
19{
20for (int i = 0; i < 50; i++)
21{
22
23string dir = Path.Combine(thisFolder, directory1);
24if (Directory.Exists(dir))
25return dir;
26thisFolder = Directory.GetParent(thisFolder).FullName;
27
28}
29}
30catch { return ""; }
31return "";
32}
33}
34}
35