[英]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; 我正在尝试学习如何反序列化和序列化JSON,但是在对象序列化后,Web应用程序将输出json文件的当前目录。 is in the c:/user/ProgramFiles(x86)/IISExpress/-folder.
在c:/ user / ProgramFiles(x86)/ IISExpress /文件夹中。
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”. 我无法访问已手动移动到我的App_Data文件夹的json文件,因为它显示“找不到文件”。 It also gives me “Access to the path 'C:\\Program Files (x86)\\IIS Express\\Output.json' is denied.” For some reason.
它也给我“拒绝访问路径'C:\\ Program Files(x86)\\ IIS Express \\ Output.json'。”由于某种原因。
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: 由于您尝试从App_Data的文件中反序列化json,因此我相信您可以将所有内容都放入这样的变量中:
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. 之所以给您“拒绝访问路径X”的原因,是因为您没有以管理员身份运行Visual Studio。 Try right-clicking the VS-icon and click “Run as administrator”, and try again.
尝试右键单击VS图标,然后单击“以管理员身份运行”,然后重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.