54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
// /**
|
|
// * 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<string>)search);
|
|
public static string FindPath(IEnumerable<string> 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<string>)search);
|
|
public static string FindDirectory(IEnumerable<string> 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<string>)search);
|
|
public static string FindFile(string filename, IEnumerable<string> search)
|
|
{
|
|
foreach (string p in search)
|
|
{
|
|
String path = Path.Combine(p, filename);
|
|
if (File.Exists(path))
|
|
return path;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|