如何授予我们要阅读的JSON文件的权利?

发布于 2025-01-22 07:45:41 字数 629 浏览 1 评论 0原文

我正在尝试在我的本地主机上阅读使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟到的我 2025-01-29 07:45:41

我认为您无法访问该文件,因为由于其位置而没有阅读许可。
手动将其移动到另一个文件夹,然后重试

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文