如何授予我们要阅读的JSON文件的权利?
我正在尝试在我的本地主机上阅读使用Web应用程序的JSON文件。我一直遇到相同的错误:
访问路径'c:\ users \ admin \ documents \ test \ response.json'的访问被拒绝。似乎它可以找到该文件,但无法读取。
这是我尝试读取文件的方式:
using (StreamReader reader = new StreamReader("C:\Users\Admin\Documents\test\response.json"))
{
string fileContent = reader.ReadToEnd();
JObject resultASJtoken = JObject.Parse(fileContent);
return resultASJtoken;
}
我还尝试使用icacls powershell
命令更改正确的权利,但似乎并不有效。
icacls "C:\Users\Admin\Documents\test\response.json" /grant Admin:F /T
如果有人有一个主意,我真的很感谢您的帮助。
I'm trying to read a JSON file with a web application on my localhost. I keep getting the same error:
Access to the path 'C:\Users\Admin\Documents\test\response.json' is refused. It seems like it can find the file but can't read it.
Here is how I try to read the file:
using (StreamReader reader = new StreamReader("C:\Users\Admin\Documents\test\response.json"))
{
string fileContent = reader.ReadToEnd();
JObject resultASJtoken = JObject.Parse(fileContent);
return resultASJtoken;
}
I've also tried to change my right using icacls powershell
command but it doesn't seems effective.
icacls "C:\Users\Admin\Documents\test\response.json" /grant Admin:F /T
If someone has an idea, I would really appreciate some help in this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您无法访问该文件,因为由于其位置而没有阅读许可。
手动将其移动到另一个文件夹,然后重试
I think you don't have access to the file because you don't have read permission due to its position.
Move it to another folder manually and try again