我有一个返回文件内容的类库项目(NotificationTemplate):
public static class Template
{
public static string NotificatioEmail
{
get { return File.ReadAllText("Templates\\NotificatioEmail.cshtml"); }
}
}
在这个项目中,位于Templates
带有NotificatioEmail.cshtml
文件的文件夹中。
另外,我有两个应用程序:控制台应用程序和 ASP.NET MVC 应用程序。该文件在控制台应用程序中返回正常,但在 MVC 中出现错误file not found
。怎么写万能?
我试过这个:
Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Templates",
"NotificatioEmail.cshtml")
但BaseDirectory
不包括bin
文件夹。