文件夹 文件 加入/去除 Everyone全控
文件夹 加入/去除 Everyone全控

Code

文件夹 加入/去除 Everyone全控#region 文件夹 加入/去除 Everyone全控
protected void Button2_Click(object sender, EventArgs e)


{

/**/////--增加方法1
//string DirectoryName = "D:\\Free";
//DirectoryInfo dInfo = new DirectoryInfo(DirectoryName);
//DirectorySecurity dSecurity = dInfo.GetAccessControl();
//dSecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow));
//dInfo.SetAccessControl(dSecurity);


/**/////--去除方法1
//string DirectoryName = "D:\\Free";
//DirectoryInfo dInfo = new DirectoryInfo(DirectoryName);
//DirectorySecurity dSecurity = dInfo.GetAccessControl();
//dSecurity.RemoveAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow));
//dInfo.SetAccessControl(dSecurity);


/**/////--增加方法2
//string fileName = "D:\\Free"; ;
//string strArguments = " /C Cacls " + fileName + " /t /e /c /g Everyone:f";
//System.Diagnostics.Process process = new System.Diagnostics.Process();
//process.StartInfo.CreateNoWindow = true;
//process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//process.StartInfo.FileName = "cmd.exe";
//process.StartInfo.Arguments = strArguments;
//process.Start();


/**/////--去除方法2
//string fileName = "D:\\Free"; ;
//string strArguments = " /C Cacls " + fileName + " /t /e /c /r Everyone";
//System.Diagnostics.Process process = new System.Diagnostics.Process();
//process.StartInfo.CreateNoWindow = true;
//process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//process.StartInfo.FileName = "cmd.exe";
//process.StartInfo.Arguments = strArguments;
//process.Start();

}
#endregion
文件 加入/去除 Everyone全控

Code

文件 加入/去除 Everyone全控#region 文件 加入/去除 Everyone全控
protected void Button1_Click(object sender, EventArgs e)


{

/**/////--增加方法1
//string fileName = "D:\\Free.txt";
//FileSecurity fSecurity = File.GetAccessControl(fileName);
//fSecurity.AddAccessRule(new FileSystemAccessRule("Everyone",FileSystemRights.FullControl,AccessControlType.Allow));
//File.SetAccessControl(fileName, fSecurity);


/**/////--去除方法1
//string fileName = "D:\\Free.txt";
//FileSecurity fSecurity = File.GetAccessControl(fileName);
//fSecurity.RemoveAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow));
//File.SetAccessControl(fileName, fSecurity);


/**/////--增加方法2
//string fileName = "D:\\Free.txt"; ;
//string strArguments = " /C Cacls " + fileName + " /t /e /c /g Everyone:f";
//System.Diagnostics.Process process = new System.Diagnostics.Process();
//process.StartInfo.CreateNoWindow = true;
//process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//process.StartInfo.FileName = "cmd.exe";
//process.StartInfo.Arguments = strArguments;
//process.Start();


/**/////--去除方法2
//string fileName = "D:\\Free.txt"; ;
//string strArguments = " /C Cacls " + fileName + " /t /e /c /r Everyone";
//System.Diagnostics.Process process = new System.Diagnostics.Process();
//process.StartInfo.CreateNoWindow = true;
//process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//process.StartInfo.FileName = "cmd.exe";
//process.StartInfo.Arguments = strArguments;
//process.Start();

}
#endregion
cacls /?

Code
Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator>cacls /?
显示或者修改文件的访问控制列表(ACL)

CACLS filename [/T] [/M] [/S[:SDDL]] [/E] [/C] [/G user:perm] [/R user [
]]
[/P user:perm [
]] [/D user [
]]
filename Displays ACLs.
/T 更改当前目录及其所有子目录中指定
文件的 ACL。
/M 将装入卷的 ACL 更改到目录。
/S 显示 DACL 的 SDDL 字符串。
/S:SDDL 用 SDDL 字符串中指定的 ACL 替换
(与 /E、/G、/R、/P 或 /D 一起使用时无效)。
/E 编辑 ACL 而不替换。
/C 在出现拒绝访问错误时继续。
/G user:perm 赋予指定用户访问权限。
Perm 可以是: R 读取
W 写入
C 更改(写入)
F 完全控制
/R user 撤销指定用户的访问权限(仅在与 /E 一起使用时合法)。
/P user:perm 替换指定用户的访问权限。
Perm 可以是: N 无
R 读取
W 写入
C 更改(写入)
F 完全控制
/D user 拒绝指定用户的访问。
在命令中可以使用通配符指定多个文件。也可以在命令中指定
多个用户。

缩写:
CI - 容器继承。
ACE 会由目录继承。
OI - 对象继承。
ACE 会由文件继承。
IO - 只继承。
ACE 不适用于当前文件/目录。

C:\Documents and Settings\Administrator>
















































文件 加入/去除 Everyone全控














































cacls /?















































posted on 2008-04-08 14:30 freeliver54 阅读(755) 评论(4) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步