访问路径“”在C#中被拒绝 [英] Access to the path "" is denied in C#

查看:382
本文介绍了访问路径“”在C#中被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在C驱动器中有一个XML文件。我想更新并使用C#保存该xml。保存xml时会抛出错误。错误是 访问路径'C:\inetpub \wwwroot \sites\mysite \ App_Data \ roll.xml'被拒绝。如何诊断这个问题



谢谢,



问候,

Ramadurai U

解决方案

信用转到ThePhantomUpvoter,因为他说你只需要更改你的权限,这样运行网站的用户就有权编辑文件......


更改IIS用户的权限,请按照以下步骤操作:

http ://support.microsoft.com/kb/308419 [ ^ ]


如果这是Windows 7(或Vista),则此位置不合法。但是不要将其更改为D:,甚至可能不会更改权限。以合法的方式更好地使用目录。请参阅我过去的回答:

如何找到我的程序目录 [ ^ ]。



如果这是一个Web应用程序,则不能使用目录配置之外的任何目录作为站点的根目录。 Web应用程序在沙盒环境中运行,无论文件系统权限如何,都不允许访问项目目录树的大小。



-SA

Hi ,

I have a XML file in "C" Drive . I want to update and to save that xml using C#. While saving the xml it is throwing error. The error is "Access to the path 'C:\inetpub\wwwroot\sites\mysite\App_Data\roll.xml' is denied". How to diagnose this problem

Thank you,

Regards,
Ramadurai U

解决方案

Credit goes to ThePhantomUpvoter, as he said you just need to change your permissions so that the user running the site will have permission to edit files...


Change the permissions for IIS user, follow this:
http://support.microsoft.com/kb/308419[^]


If this is Windows 7 (or Vista) this location is not legal. But don't "change it to D:", and probably don't even change permissions. Better use the directories in a legitimate way. Please see my past answer:
How to find my programs directory[^].

If this is a Web application, you cannot use any directories beyond the directory configures as the root directory for your site. Web applications are run in a sandboxed environment which won't allow access outsize of your project directory tree, regardless of the file system permissions.

—SA


这篇关于访问路径“”在C#中被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆