Question: How do you get a path to a file in ASP.Net (Dot Net) Core 2.2 Application?
Login to See the Rest of the Answer
Answer: Create a seperate function that will handle that behaviour, creating a separate file is good for modularity and code reusability. See the code below:
public static string GetAbsolutePath(string relativePath)
{
FileInfo _dataRoot = new FileInfo(typeof(Program).Assembly.Location);
string assemblyFolderPath = _dataRoot.Directory.FullName;
string fullPath = Path.Combine(assemblyFolderPath, relativePath);
return fullPath;
}