如何从C#/.net中的帮助程序获取内容文件的路径

如何从C#/.net中的帮助程序获取内容文件的路径,c#,.net,asp.net-mvc-4,C#,.net,Asp.net Mvc 4,这是我在VS 2012解决方案资源管理器中的解决方案结构: abcWeb - Properties - References - Service References - App_Data - Areas - -abcArea - - - Controlers - - - - abcController - - - ViewModels - - - - abcViewModel - - - Views - - - - abcView - Content - - css

这是我在VS 2012解决方案资源管理器中的解决方案结构:

abcWeb
 - Properties
 - References
 - Service References
 - App_Data
 - Areas
 - -abcArea
 - - - Controlers
 - - - - abcController
 - - - ViewModels
 - - - - abcViewModel
 - - - Views
 - - - - abcView
 - Content
 - - css
 - - images
 - - fonts
 - - scripts
 - - templates
 - - - abc.html   
 - Globals
 - Helpers
 - - abcHelper.cs 
. . .
我的问题是:

我有一种在
abcHelper
中发送电子邮件的方法,该方法从内容/模板中读取abc.html文件,作为电子邮件正文。在
System.IO.File.ReadAllText(…)
函数中作为参数传递的字符串路径是什么

方法如下:

    public void SendWelcomeTemplate()
    {
        string templatePath = @"../Content/templates/abc.html"; // This doesn't work!

        var emailBody = System.IO.File.ReadAllText(templatePath);

        SendEmail(strToEmailAddress, strEmailSubject, emailBody);
    }
非常感谢您的帮助。

试试这个

string templatePath = Server.MapPath("/Content/templates/abc.html");

你试过
~
@“~/Content/templates/abc.html”
@christiandev是的,这让我非常感谢你!这对我有用。我使用了:var templatePath=HttpContext.Current.Server.MapPath(“/Content/templates/abc.html”);