注册地在.NET:DeleteSubKeyTree说该子项不存在,但是,嘿,它确实!不存在、确实、NET、DeleteSubKeyTree

由网友(薄衫少年、)分享简介:试图删除一个子项树: HKEY_CURRENT_USER \软件\微软\的Windows \ CurrentVersion \ Explorer中\ FileExts \的.hdr 。 的.hdr 子项中有一个子项,没有任何价值。所以我用这个code:Trying to delete a subkey tree: H...

试图删除一个子项树: HKEY_CURRENT_USER 软件微软的Windows CurrentVersion Explorer中 FileExts 的.hdr 的.hdr 子项中有一个子项,没有任何价值。所以我用这个code:

Trying to delete a subkey tree: HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.hdr. .hdr subkey has one subkey, no values. So I use this code:

RegistryKey FileExts = Registry.CurrentUser.CreateSubKey("SOFTWAREMicrosoftWindowsCurrentVersionExplorerFileExts");
RegistryKey faulty = FileExts.OpenSubKey(".hdr");
Debug.Assert (faulty != null && faulty.SubKeyCount != 0);
faulty.Close();
FileExts.DeleteSubKeyTree(".hdr");

和我得到的的ArgumentException 与消息无法删除子树,因为该子项不存在的。

And I get the ArgumentException with message "Cannot delete a subkey tree because the subkey does not exist."

跆拳道?我检查,并声称它确实存在?

WTF? I checked and asserted it did exist?

状态更新

寻求与过程监控,的.hdr的子项得到了交通运行code时,会拒绝错误。我查了autorizations,但他们已经很好了?

Seeking with Process Monitor, the subkey of ".hdr" gets a ACCESS DENIED error when running the code. I checked the autorizations, but they look fine?

推荐答案

找到了解决办法,这引起了其他另外一个问题... 的

指向访问被拒绝误差进程监视器后,我只是想单独删除子项:

After pointing the ACCESS DENIED error with Process Monitor, I just tried to delete subkeys individually:

RegistryKey hdr = FileExts.OpenSubKey(".hdr", true);
foreach (String key in hdr.GetSubKeyNames())
   hdr.DeleteSubKey(key);
hdr.Close();
FileExts.DeleteSubKeyTree(".hdr");

它工作得很好,所以它不是一个权限问题!

It worked fine, so it's not a permission problem!

对于原因,我不明白,DeleteSubKeyTree需要一个空的树工作。

For a reason I don't understand, DeleteSubKeyTree needed an empty tree to work.

这是解释,任何人吗?

阅读全文

相关推荐

最新文章