简体   繁体   中英

Unable to reach IIS Express folder from solution

I'm trying to learn how to deserialize and serialize JSON, but the current directory which my web application outputs the json-file after serialization of my objects; is in the c:/user/ProgramFiles(x86)/IISExpress/-folder.

I am unable to reach the json-file which I have manually moved to my App_Data-folder as it says “it cannot find file”. It also gives me “Access to the path 'C:\\Program Files (x86)\\IIS Express\\Output.json' is denied.” For some reason.

How would I go about solving the map-path as I have tried in my code to direct me to the right directory within the solution?

Since you are trying to deserialize json from a file from App_Data, I believe you could put everything in a variable like this:

string json = System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath(“/App_Data/Output.json”));

The reason it gives you the “Access to the path X is denied”, is because you are not running Visual Studio as an administrator. Try right-clicking the VS-icon and click “Run as administrator”, and try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM