private string GetPhysicalFilePath(string filePath)
{
#if NETSTANDARD1_6 || NET451
string applicationDirectoryPath = _hostingEnvironment.ContentRootPath;
#elif NET40
HttpContext context = HttpContext.Current;
string applicationDirectoryPath = context.Server.MapPath("~/");
#else
#error No implementation for this target
#endif
string physicalFilePath = Path.Combine(
applicationDirectoryPath,
filePath.Replace('/', '\\').TrimStart(new char[] { '\\' })
);
return physicalFilePath;
}
}