我们如何在C#中添加写访问的目录编程? [英] How we can add write access to a directory programmatically in C#?

查看:142
本文介绍了我们如何在C#中添加写访问的目录编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建目录的ASP.NET页面,而在另一个页面我上传一些文件,这些文件夹,但是当我在一个目录上传文件,会出现以下错误:

 的路径我的路访问被拒绝。


解决方案

您code下不具有到指定目录的写权限的用户帐户运行,因此这是不可能相同的用户将有机会获得更改权限。这意味着你将不能被这种情况下下运行时,从code更改权限。请记住,code可以做的不多(权限WISE)不是用户帐户允许。

您需要手动设置的目录(或父目录)的权限,使ASP.NET用户可以写入它。

I have an ASP.NET page that creates directories, and in another page I upload some files in these folders, but when I upload a file in a directory, the below error appears:

Access to the path 'my path' is denied.

解决方案

Your code is running under a user account that does not have write access to the specified directory, so it is unlikely that same user would have access to change the permissions. This means that you will not be able to change the permissions from your code while it is running under that context. Remember that the code can do no more (permissions wise) than the user account allows.

You will need to set the permissions on the directory (or a parent directory) manually so that the ASP.NET user can write to it.

这篇关于我们如何在C#中添加写访问的目录编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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