NetCore中读取根目录下的文件名
//获取根目录
public static string GetBaseDir()
{
var currentAssembly = typeof(CertificateHelper).GetTypeInfo().Assembly;
var root = Path.GetDirectoryName(currentAssembly.Location);
var idx = root.IndexOf($"{Path.DirectorySeparatorChar}bin", StringComparison.OrdinalIgnoreCase);
return root.Substring(0, idx);
}
//获取模板路径
public static string GetPdfTemplatePath()
{
return Path.Combine(GetBaseDir(), "文件夹的名字", "文件名");
}