问题描述
我遇到的问题确实使我丧命.
I am having an issue that is really killing me.
我有一个目录,当我进入属性窗口时,它显示为部分选中的只读"状态(不是完整的复选框,但该复选框已填充).
I have a directory that when I go to the properties window, shows Read-Only as partially checked (not a full check box, but the box is filled).
因此,我查看了目录,并检查了所有文件,其中无都具有只读属性.只有文件夹有它,并且只有一部分.
So I looked in the directory and I checked all the files, none of them have the read-only attribute. Only the folder has it, and only partially.
我尝试了以下代码:
if (directoryInfo.Exists)
{
try
{
directoryInfo.Attributes &= ~FileAttributes.ReadOnly;
foreach (FileInfo f in directoryInfo.GetFiles())
{
f.IsReadOnly = false;
}
}
catch (Exception e)
{
throw e;
}
}
它仍然无法正常工作.我可以右键单击该文件夹,然后手动删除只读权限,但是我需要才能在代码中执行此操作.该代码可以执行,但不会出错.
It still did not work. I can right click on the folder and manually remove the read-only permissions but I need to be able to do this in code. The code executes but does not error.
任何人都不知道可能是什么问题?我唯一的猜测是因为文件夹位于网络共享上(以\\ computer \ folder \ subfolder的形式),所以我可能需要特殊权限才能更改文件夹的权限?
Anyone have any idea what the issue could be? My only guess is because the folder is on a network share (in the form of \\computer\folder\subfolder), that I might need special rights in order to change permissions on a folder?
请有人帮忙.
预先感谢
推荐答案
只读...如果您确实需要更改它,则需要进行一些工作(注册表和更改许多文件夹). .请参见 http://support.microsoft.com/kb/256614/zh-CN
readonly on folders is used by Windows internally... if you really need to change it then is some work involved (Registry and changing alot of folders)... see http://support.microsoft.com/kb/256614/en-us
您为什么需要进行更改?
Why do you need to make that change ?
编辑-有关Powershell和TFS的一些信息:
EDIT - some information on Powershell and TFS:
或尝试在文件夹中使用"attrib -r
"的普通批处理文件"(.bat)
or try a normal "batch file" (.bat) with "attrib -r
" on the folder
这篇关于删除网络共享上文件夹上的只读属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!