我们是否需要管理员权限才能使用File.WriteAllText写入文件?当我试着叫它的时候,我得到了System.UnauthorizedAccessException。
这是我的代码:
public void JsonHashTagWrite(string vrednost, string path)
{
string json = File.ReadAllText(path);
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
jsonObj["envVariablesConditions"]["initEnvVariables"][26]["value"] = "#" + vrednost;
string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj,
Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(path, output);
}发布于 2021-12-28 15:38:27
Visual需要管理员权限。
https://stackoverflow.com/questions/70509138
复制相似问题