文件I/O权限 [英] File I/O permissions
问题描述
您好,专家,
我有一个正在运行的WindowsXP,带有3个用户:Admin,User1和User2.管理员是管理员(您已经猜到了).
两个用户都是受限用户.
现在,我的印象是,User1创建的每个文件都可以由他自己或由Admin更改/删除.但是User2即使阅读也没有机会做任何事情.
我试过在一些特殊的文件夹"Dokumente und Einstellungen \ All Users \ Dokumente"中(这是德语WinXP,英语应该是"Documents and Properties \ All Users \ Documents"之类的东西).结果符合我的预期:
User1创建一个文件,User2可以读取它,Admin可以执行他想要的任何操作.
现在,在上面的规则的第二个分区D:\(NTFS,全部都是)上似乎不适用.
同样,User1创建一个文件,而User2可以执行他想做的任何事情,就像Admin.
实际上,所描述的行为(在D:\上)是我想要实现的:我正在搜索目录以序列化项目文件.无论是谁创造的,任何人都应被允许开放和改变.
我只是不确定在目标计算机上是否会有目录"D:\".
在WindowsXP,2000,Vista,7中是否存在一般规则,即目录的行为就像我在"D:\"中看到的一样?
我似乎通过在所有用户\文档\"中创建目录并更改该目录的权限来获得所需的内容.我是通过点击等手动完成的.
使其成为编程问题:如何将文件夹的文件I/O权限更改为每个人都可以使用文件夹以及所有子文件夹和文件来做所有事情"?
我的第一次尝试是:
Hi experts,
I have a running WindowsXP with 3 users: Admin, User1 and User2. The Admin is administrator (you already guessed that).
Both users are restricted users.
Now I was under the impression that every file that User1 created could be changed/deleted by himself or by Admin. But User2 would have no chance to ever do something despite reading.
I tried that in some special folder "Dokumente und Einstellungen\All Users\Dokumente" (It''s a german WinXP, english should be something like "Documents and Properties\All Users\Documents"). The result was as I had expected:
User1 creates a file, User2 can read it, Admin can do whatever he wants.
Now, on the second partition D:\ (NTFS, all of them) above rules don''t seem to apply.
User1, again, creates a file and User2 can do whatever he wants, just like Admin.
Actually, the described behaviour (on D:\) is what I want to achieve: I am searching for a directory to serialize project files to. Everybody shall be allowed to open and change, no matter who created it.
I just can''t be sure that on the target machine there will be a directory "D:\".
Is there, in WindowsXP, 2000, Vista, 7 a general rule what directories would behave like I saw happen in "D:\"?
I seem to get what I want by creating a directory within "All Users\Documents\" and changing that directory''s permissions. I did that manually by clicking and such.
To make this a programming question: How can I change the file I/O permissions for a folder to "Everyone may do everything with folder and all sub-folders and files"?
My first try was this one:
using System.Security;
using System.Security.Permissions;
private void PermitEverything(string filename)
{
NamedPermissionSet ps = new NamedPermissionSet(
"SamplePermissionSet",
PermissionState.None
);
ps.AddPermission(
new FileIOPermission(FileIOPermissionAccess.AllAccess, filename)
);
ps.AddPermission(
new SecurityPermission(SecurityPermissionFlag.Execution)
);
}
它不起作用.权限保持不变,甚至不会出现错误.
Edit2:我应该注意到,这是有关.NET 2.0 WinForms应用程序的.
It doesn''t work. Permissions stay as they were without even giving an error.
I should have noted that this is about a .NET 2.0 WinForms application.
推荐答案
这实际上不是编程问题.
您可以从这里开始查找其工作方式: http://technet.microsoft.com /en-us/library/cc757422(WS.10).aspx [ ^ ].
—SA
This is not really a programming Question.
You can find out how it works starting here: http://technet.microsoft.com/en-us/library/cc757422(WS.10).aspx[^].
—SA
这篇关于文件I/O权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!