40 lines
886 B
C#
40 lines
886 B
C#
namespace ZA.CoreService.ESBCertificateManager.Services;
|
|
|
|
public static class PathResolver
|
|
{
|
|
public static string ResolvePath(string path)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
{
|
|
return path;
|
|
}
|
|
|
|
if (Path.IsPathRooted(path))
|
|
{
|
|
return Path.GetFullPath(path);
|
|
}
|
|
|
|
return Path.GetFullPath(
|
|
Path.Combine(
|
|
AppContext.BaseDirectory,
|
|
path));
|
|
}
|
|
|
|
public static string ResolveRequiredFile(
|
|
string configuredPath,
|
|
string description)
|
|
{
|
|
string resolvedPath =
|
|
ResolvePath(configuredPath);
|
|
|
|
if (!File.Exists(resolvedPath))
|
|
{
|
|
throw new FileNotFoundException(
|
|
$"{description} wurde nicht gefunden.",
|
|
resolvedPath);
|
|
}
|
|
|
|
return resolvedPath;
|
|
}
|
|
}
|