我在 Visual Studio 中有这个解决方案
MicrosoftVisualStudioSolution //being click to open solution
MainfolderSolution
-Model
---Sample.model
-Scripts
---Index.js
-Contents
---text.json
来 self 的 Sample.model 的代码
{
try
{
string temp = Path.Combine(Directory.GetCurrentDirectory(), @"..\Contents\text.json");
string Data = File.ReadAllText(temp);
}
catch
{
return null;
}
}
我的问题是找不到text.json
最佳答案
使用-
var path = System.Web.HttpContext.Current.Server.MapPath(@"~/Content/test.json");
关于javascript - 如何在C#中声明相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34848062/