访问临时Internet文件时出现System.UnauthorizedAccessException

时间:2012-10-04 07:35:57

标签: c#-3.0

我创建了一个用于清除临时Internet文件的实用程序,但是当应用程序尝试访问Internet临时文件时,会出现异常

“System.UnauthorizedAccessException:拒绝访问路径'c:\ users \ test \ AppData \ Local \ Temporary Internet Files'。”

应用程序从管理员帐户运行,UAC已关闭。 我在Windows 7企业版N 64位上运行代码

我也试图删除安全措施但没有任何事情发生。

public static void RemoveDirectorySecurity(string FileName, string Account,      
FileSystemRights Rights, AccessControlType ControlType)
    {
        // Create a new DirectoryInfo object.
        DirectoryInfo dInfo = new DirectoryInfo(FileName);

        // Get a DirectorySecurity object that represents the  
        // current security settings.
        DirectorySecurity dSecurity = dInfo.GetAccessControl();

        // Add the FileSystemAccessRule to the security settings. 
        dSecurity.RemoveAccessRule(new FileSystemAccessRule(Account,
                                                        Rights,
                                                        ControlType));

        // Set the new access settings.
        dInfo.SetAccessControl(dSecurity);

    }

有任何解决此问题的建议吗?

感谢和问候

0 个答案:

没有答案