C#创建文件夹并设置权限
原文地址:https://www.cnblogs.com/top5/archive/2010/04/12/1710141.html
/*
需要添加以下命名空间:
using System.IO;
using System.Security.AccessControl;
*/
string sPath = Server.MapPath(文件夹名称字符串);
Directory.CreateDirectory(sPath);
addpathPower(sPath, "ASPNET", "FullControl");
//////////////////////////////////////////////////
public void addpathPower(string pathname, string username, string power)
{
DirectoryInfo dirinfo = new DirectoryInfo(pathname);
if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)
{
dirinfo.Attributes = FileAttributes.Normal;
}
//取得访问控制列表
DirectorySecurity dirsecurity = dirinfo.GetAccessControl();
switch (power)
{
case "FullControl":
dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
break;
case "ReadOnly":
dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Read, AccessControlType.Allow));
break;
case "Write":
dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Write, AccessControlType.Allow));
break;
case "Modify":
dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Modify, AccessControlType.Allow));
break;
}
dirinfo.SetAccessControl(dirsecurity);
}
C#创建文件夹并设置权限的更多相关文章
- php创建文件夹后设置文件夹权限(转)
原文链接:http://www.phpstudy.net/b.php/69873.html PHP mkdir()无写权限的问题解决方法 使用mkdir创建文件夹时,发现这个函数有两个参数,第二个参数 ...
- mac home目录创建文件夹,修改权限
mac 是基于unix, 自带就有home目录,但是为空.home目录的默认所属用户是root wheel,mac默认的root账号所属用户是root admin,所以root也无法在home目录下创 ...
- Linux_修改创建文件夹时默认权限(修改为能上传)
1:查看当前权限 umask 0022 意思就是权限为:777-022 =755 读 2:临时修改 umask 020 020 意思为:777-020=757 读写上传 3:永久修改 回到根目录 cd ...
- Mac home目录下,创建文件夹,修改权限
http://php-note.com/article/detail/35e782e145a94042923946cb142b5cd1 1.关闭 SIP 2.sudo mount -uw /
- ubuntu下无法在目录下创建文件夹,权限不足解决办法
问题详情:偶然在根目录创建文件夹的时候,突然显示错误,当时很惊讶,以前没遇见过这样的问题.当时界面是这样的. 用了一个 cd / 命令从用户磁盘跳到了根目录 使用 mkdir 命令准备创建一个文件夹, ...
- C# 代码实现设置用户"NETWORK SERVICE"具有对文件夹的读取权限。
设置用户"NETWORK SERVICE"具有对文件夹的读取权限. 原帖地址: http://www.cnblogs.com/sjhrun2001/archive/2009/03/ ...
- Ubuntu上使用过的命令,Linux常用命令,mount 硬盘挂载, ls 列表list命令,cp 复制copy命令,mkdir 创建文件夹 ,nano 编辑器,cat 文档合并,chmod 文件权限,ssh win10连接ubuntu服务器的步骤
man 帮助 > man ls # ubuntu的帮助 tar.gz 压缩解压 > tar -zcvf yzn.tar.gz /home/yzn # 压缩 > tar -zxvf y ...
- android下创建文件夹和修改其权限的方法
原文:http://www.cnblogs.com/wanqieddy/archive/2011/12/28/2304906.html 由于工作的需要,今天研究了在android下创建文件夹和修改其权 ...
- 【每天一个Linux命令】19. 创建文件夹目录命令mkdir
命令用途 mkdir 命令用来创建指定的名称的目录 使用说明 1. 创建目录的用户在当前目录中具有写权限 2. 指定的目录名不能是当前目录中已有的目录. 命令实例 0. 帮助文件 bixiaopen ...
随机推荐
- windows系统tomcat日志输出至catalina.out配置说明
转自:https://blog.csdn.net/liubowin/article/details/48001947 1.修改bin/startup.bat文件 修改前:call "%EXE ...
- 【代码片段】如何使用CSS来快速定义多彩光标
对于web开发中,我们经常都看得到需要输入内容的组件和元素,比如,textarea,或者可编辑的DIV(contenteditable) ,如果你也曾思考过使用相关方式修改一下光标颜色的,那么这篇技术 ...
- 创建mysql数据库并指定编码
xplanner的readme.txt里有句话“XPlanner has only been tested on mysql 4.x, myslq 5.0, Tomcat 5.x, java 1.4, ...
- 【转】Spring MVC处理静态资源
优雅REST风格的资源URL不希望带 .html 或 .do 等后缀.由于早期的Spring MVC不能很好地处理静态资源,所以在web.xml中配置DispatcherServlet的请求映射,往往 ...
- jQuery的md5加密插件及其它js md5加密代码
/** * jQuery MD5 hash algorithm function * * <code> * Calculate the md5 hash of a String * Str ...
- Using a Microsoft Account to Logon and Resulting Internet Communication in Windows 8
Using a Microsoft Account to Logon and Resulting Internet Communication in Windows 8 此主题尚未评级 - 评价此主题 ...
- Converter Standardalone 5 versus Converter Boot CD
The new Converter Standalone 5 lacks the Converter Boot CD. Fortunately you can still use the old ve ...
- sql按分时段统计
),,) ctime, ) num FROM [eschool_1].[dbo].kg_Kaoqin ),,) ),,)
- 在cmd中为命令设置别名以及启动cmd时自动执行bat
http://www.cnblogs.com/fstang/archive/2013/04/06/3002006.html 简短步骤: 1.关闭所有在运行的CMD窗口 2.创建文件C:\cmd-ali ...
- unable to find the sources of your current Linux kernel.
运行 sh ./VBoxLinuxAdditions.run 时FAILED,查看日志: /tmp/vbox.0/Makefile.include.header:97: *** Error: unab ...