Files
123123/ZA.CoreService.ESBCertificateManager/Services/PathResolver.cs
2026-07-28 08:03:12 +02:00

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;
}
}