如何在c#、mvc中为字符串分配映射路径
How to assign a map path to a string in c#, mvc
我正在用我的网站发送附件project.I使用下面的代码给出本地路径
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailStyle/TD-emailForCus.html")))
{
body = reader.ReadToEnd();
}
那么这可行properly.but我想这样做。
stirng mypath = stirng.Format("~/EmailStyle/TD-emailForCus.html");
using (StreamReader reader = new StreamReader(Server.MapPath(mypath)))
{
body = reader.ReadToEnd();
}
当我这样做时,它不起作用 properly.how 我可以给一个地图路径吗 this.hope 你的 help.thanx.
喜欢 this.get 你的完整 Server.MapPath()
到这样的变量然后调用它,
var mypath = Server.MapPath("~/EmailStyle/TD-emailForCus.html");
using (StreamReader reader = new StreamReader(mypath))
{
body = reader.ReadToEnd();
}
这对你有帮助。
我正在用我的网站发送附件project.I使用下面的代码给出本地路径
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailStyle/TD-emailForCus.html")))
{
body = reader.ReadToEnd();
}
那么这可行properly.but我想这样做。
stirng mypath = stirng.Format("~/EmailStyle/TD-emailForCus.html");
using (StreamReader reader = new StreamReader(Server.MapPath(mypath)))
{
body = reader.ReadToEnd();
}
当我这样做时,它不起作用 properly.how 我可以给一个地图路径吗 this.hope 你的 help.thanx.
喜欢 this.get 你的完整 Server.MapPath()
到这样的变量然后调用它,
var mypath = Server.MapPath("~/EmailStyle/TD-emailForCus.html");
using (StreamReader reader = new StreamReader(mypath))
{
body = reader.ReadToEnd();
}
这对你有帮助。