FileIOPermission

FileIOPermissionECMA 1.0, serializable

System.Security.Permissions (mscorlib.dll)sealed class
public sealed class FileIOPermission : System.Security.CodeAccessPermission : IUnrestrictedPermission,     IBuiltInPermission { // Public Constructors    public FileIOPermission(FileIOPermissionAccess access, string path);    public FileIOPermission(FileIOPermissionAccess access, string[  ] pathList);    public FileIOPermission(PermissionState state); // Public Instance Properties    public FileIOPermissionAccess AllFiles{set; get; }    public FileIOPermissionAccess AllLocalFiles{set; get; } // Public Instance Methods    public void AddPathList(FileIOPermissionAccess access, string path);    public void AddPathList(FileIOPermissionAccess access, string[  ] pathList);    public override IPermission Copy(  );         // overrides CodeAccessPermission    public override void FromXml(System.Security.SecurityElement esd);  // overrides CodeAccessPermission    public string[  ] GetPathList(FileIOPermissionAccess access);    public override IPermission Intersect(System.Security.IPermission target);  // overrides CodeAccessPermission    public override bool IsSubsetOf(System.Security.IPermission target);  // overrides CodeAccessPermission    public bool IsUnrestricted(  );      // implements IUnrestrictedPermission    public void SetPathList(FileIOPermissionAccess access, string path);    public void SetPathList(FileIOPermissionAccess access, string[  ] pathList);    public override SecurityElement ToXml(  );    // overrides CodeAccessPermission    public override IPermission Union(System.Security.IPermission other);  // overrides CodeAccessPermission }

The FileIOPermission class represents the ability for code to access files and folders. The FileIOPermission class maintains separate lists of files and folders to which different levels of access have been granted, and therefore a single FileIOPermission object can represent different types of access to an arbitrary number of files and folders. However, only simple configurations are possible using the FileIOPermission constructors; to create more complex FileIOPermission configurations requires use of the AddPathList( ) and SetPathList( ) methods.

To create a FileIOPermission object representing access to a single file or folder, pass a System.String containing the file or folder's full path to the FileIOPermission constructor along with a value from the FileIOPermissionAccess enumeration. The FileIOPermissionAccess enumeration contains values that represent the type of access granted to a file or folder, such as permission to read, write, or append. A second constructor takes a System.String array containing the names of multiple files and folders, but takes only a single FileIOPermissionAccess value, applying the same access level to all of the files and folders.

The lists of files and folders to which each level of access is granted are managed using the SetPathList( ) and AddPathList( ) methods. Both methods take either a single or an array of System.String values specifying the full path names of the files and folders to grant the specified level of access. The AddPathList( ) method adds access of the specified type for the set of files and folders to its current list. The SetPathList( ) method replaces its existing list of file and folders of the specified access level. The AllFiles property provides a simple mechanism to specify a level of access to all files and folders regardless of location, and the AllLocalFiles property does the same, but only for files and folders on the local hard drive.

The GetPathList( ) method returns a System.String array containing the full path name of files and folders to which access of the specified level is granted. The FileIOPermissionAccess.AllAccess and FileIOPermissionAccess.NoAccess values are invalid in calls to GetPathList( ), and will throw a System.ArgumentException.

For performance reasons, the .NET file and folder classes check file access permissions only when they open a file or folder, and so care must be taken when passing file and references.

Hierarchy

System.Object System.Security.CodeAccessPermission(System.Security.IPermission, System.Security.ISecurityEncodable, System.Security.IStackWalk) FileIOPermission(IUnrestrictedPermission, IBuiltInPermission)



Programming. NET Security
Programming .Net Security
ISBN: 0596004427
EAN: 2147483647
Year: 2005
Pages: 346

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net