我有一个JSON文件。
public static string RepStatusJsonFile = @"Statuses.json";
当我尝试使用StreamReader读取它时,
public static Dictionary<string, string> LoadRepStatuses()
{
Dictionary<string, string> list = new Dictionary<string, string>();
StreamReader read = new StreamReader(RepStatusJsonFile);
string json = read.ReadToEnd();
DataSet ds = JsonConvert.DeserializeObject<DataSet>(json);
for (int i = 0; i < RepStatuses; i++)
{
list.Add(ds.Tables[0].Rows[i][0].ToString(), ds.Tables[0].Rows[i][1].ToString());
}
return list;
}
我收到此错误:
Could not find file 'C:\Windows\SysWOW64\inetsrv\statuses.json'.
答案 0 :(得分:0)
解决!
将其更改为:
StreamReader read = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(@"Statuses.json"));
感谢Mike McCaughan。