Export (0) Print
Expand All

FileIOPermission Constructor (FileIOPermissionAccess, String)

.NET Framework 1.1

Initializes a new instance of the FileIOPermission class with the specified access to the specified file or directory.

[Visual Basic]
Public Sub New( _
   ByVal access As FileIOPermissionAccess, _
   ByVal path As String _
)
[C#]
public FileIOPermission(
   FileIOPermissionAccess access,
 string path
);
[C++]
public: FileIOPermission(
   FileIOPermissionAccess access,
 String* path
);
[JScript]
public function FileIOPermission(
   access : FileIOPermissionAccess,
 path : String
);

Parameters

access
A bitwise combination of the FileIOPermissionAccess values.
path
The absolute path of the file or directory.

Exceptions

Exception Type Condition
ArgumentException The access parameter is not a valid value of FileIOPermissionAccess.

-or-

The path parameter is not a valid string.

-or-

The path parameter did not specify the absolute path to the file or directory.

Remarks

This constructor only allows one of the FileIOPermissionAccess values to be specified for the specified file or directory. Use AddPathList to define complex permissions.

Example

[Visual Basic] 
Console.WriteLine("Creating a FileIOPermission with AllAccess rights for 'C:\Examples\Test\TestFile.txt")
fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\Examples\Test\TestFile.txt")

[C#] 
Console.WriteLine("Creating a FileIOPermission with AllAccess rights for 'C:\\Examples\\Test\\TestFile.txt");
fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\\Examples\\Test\\TestFile.txt");

[C++] 
Console::WriteLine(S"Creating a FileIOPermission with AllAccess rights for 'C:\\Examples\\Test\\TestFile.txt");
fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess::AllAccess, S"C:\\Examples\\Test\\TestFile.txt");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

FileIOPermission Class | FileIOPermission Members | System.Security.Permissions Namespace | FileIOPermission Constructor Overload List

Show:
© 2014 Microsoft