有谁知道如何删除C:\ Windows \ Font中的字体文件?
我将当前用户设置为所有者,并将访问规则设置为FullControl,但仍然遇到System.UnauthorizedAccessException
异常
Dim fileS As FileSecurity = touninstall(ui).GetAccessControl
Dim idref As SecurityIdentifier = fileS.GetOwner(GetType(SecurityIdentifier))
Dim NTAccount As NTAccount = idref.Translate(GetType(NTAccount))
Console.WriteLine(NTAccount)
'Update it, Grant Current User Full Control
Dim cu As SecurityIdentifier = WindowsIdentity.GetCurrent().User
NTAccount = cu.Translate(GetType(NTAccount))
Console.WriteLine(NTAccount)
fileS.SetOwner(cu)
fileS.SetAccessRule(New FileSystemAccessRule(cu, FileSystemRights.FullControl, AccessControlType.Allow))
'Update the Access Control on the File
touninstall(ui).SetAccessControl(fileS)
'Delete the file
touninstall(ui).Delete()
我正在以管理员身份运行该应用。我认为它与文件夹/文件权限和继承有关,但不是很确定。
由于