diff --git a/PathHelper.cs b/PathHelper.cs new file mode 100644 index 0000000..0f822e7 --- /dev/null +++ b/PathHelper.cs @@ -0,0 +1,53 @@ +// /** +// * File: PathHelper.cs +// * Author: haraldwolff +// * +// * This file and it's content is copyrighted by the Author and / or copyright holder. +// * Any use wihtout proper permission is illegal and may lead to legal actions. +// * +// * +// **/ +using System; +using System.Collections.Generic; +using System.Collections; +using System.IO; +namespace ln.types +{ + public static class PathHelper + { + public static string FindPath(params string[] search) => FindPath((IEnumerable)search); + public static string FindPath(IEnumerable search) + { + foreach (string p in search) + { + if (Directory.Exists(p) || File.Exists(p)) + return Path.GetFullPath(p); + } + return null; + } + + public static string FindDirectory(params string[] search) => FindPath((IEnumerable)search); + public static string FindDirectory(IEnumerable search) + { + foreach (string p in search) + { + if (Directory.Exists(p)) + return Path.GetFullPath(p); + } + return null; + } + + public static string FindFile(string filename, params string[] search) => FindFile(filename, (IEnumerable)search); + public static string FindFile(string filename, IEnumerable search) + { + foreach (string p in search) + { + String path = Path.Combine(p, filename); + if (File.Exists(path)) + return path; + } + return null; + } + + } +} diff --git a/ln.types.csproj b/ln.types.csproj index 9288c44..52f3284 100644 --- a/ln.types.csproj +++ b/ln.types.csproj @@ -95,6 +95,7 @@ +