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.
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