DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Aniruddha has posted 40 posts at DZone. View Full User Profile

How To Check Assembly's Permissions In C#

  • submit to reddit
        Use following snippet to check whether your assembly has been granted write permission to a resource. You can check for many types of permissions by using the correct FileIOPermissionAccess enumeration

FileIOPermission fileIoPermission = new FileIOPermission(FileIOPermissionAccess.Write, @"C:\windows\system32");

            if (SecurityManager.IsGranted(fileIoPermission))
                //Write Access allowed to your assembly
                //Write permission denied


Snippets Manager replied on Wed, 2010/10/27 - 2:38pm

WTH is tht comment..