FileIOPermission.GetPathList Method (FileIOPermissionAccess)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets all files and directories with the specified FileIOPermissionAccess.

Namespace:   System.Security.Permissions
Assembly:  mscorlib (in mscorlib.dll)

Public Function GetPathList (
	access As FileIOPermissionAccess
) As String()


Type: System.Security.Permissions.FileIOPermissionAccess

One of the FileIOPermissionAccess values that represents a single type of file access.

Return Value

Type: System.String()

An array containing the paths of the files and directories to which access specified by the access parameter is granted.

Exception Condition

access is not a valid value of FileIOPermissionAccess.


access is AllAccess, which represents more than one type of file access, or NoAccess, which does not represent any type of file access.

Use this method to get the state of the current permission. To get the state of both Read and Write access, two calls to this method are required.


The access parameter is limited to the values of FileIOPermissionAccess, which represent single types of file access. Those values are Read, Write, Append, and PathDiscovery. The values acceptable to access do not include NoAccess and AllAccess, which do not represent single types of file access.

The following code example shows the use of the GetPathList method. This example is part of a larger example provided for the FileIOPermission class.

Private Function SetGetPathListDemo() As Boolean
        Console.WriteLine("********************************************************" & ControlChars.Lf)

        Dim fileIOPerm1 As FileIOPermission
        Console.WriteLine("Creating a FileIOPermission with AllAccess rights for 'C:\Examples\Test\TestFile.txt")
        fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\Examples\Test\TestFile.txt")
        Console.WriteLine("Adding 'C:\Temp' to the write access list, and " & ControlChars.Lf & " 'C:\Examples\Test' to read access.")
        fileIOPerm1.AddPathList(FileIOPermissionAccess.Write, "C:\Temp")
        fileIOPerm1.AddPathList(FileIOPermissionAccess.Read, "C:\Examples\Test")
        Dim paths As String() = fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
        Console.WriteLine("Read access before SetPathList = ")
        Dim path As String
        For Each path In paths
            Console.WriteLine((ControlChars.Tab & path))
        Next path
        Console.WriteLine("Setting the read access list to " & ControlChars.Lf & "'C:\Temp'")
        fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\Temp")
        paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
        Console.WriteLine("Read access list after SetPathList = ")
        For Each path In paths
            Console.WriteLine((ControlChars.Tab & path))
        Next path

        paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Write)
        Console.WriteLine("Write access list after SetPathList = ")
        For Each path In paths
            Console.WriteLine((ControlChars.Tab & path))
        Next path

        Dim pathList() As String
        pathList = fileIOPerm1.GetPathList(FileIOPermissionAccess.AllAccess)

    Catch e As ArgumentException
        ' FileIOPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
        Console.WriteLine(("An ArgumentException occurred as a result of using AllAccess. " & "This property cannot be used as a parameter in GetPathList " & "because it represents more than one type of file variable access. : " & ControlChars.Lf & e.ToString()))
    End Try

    Return True
End Function 'SetGetPathListDemo

.NET Framework
Available since 1.1
Return to top