Export (0) Print
Expand All

FileIOPermission.AllFiles Property

Gets or sets the permitted access to all files.

[Visual Basic]
Public Property AllFiles As FileIOPermissionAccess
[C#]
public FileIOPermissionAccess AllFiles {get; set;}
[C++]
public: __property FileIOPermissionAccess get_AllFiles();
public: __property void set_AllFiles(FileIOPermissionAccess);
[JScript]
public function get AllFiles() : FileIOPermissionAccess;
public function set AllFiles(FileIOPermissionAccess);

Property Value

The set of file I/O flags for all files.

Remarks

This property gets or sets the permitted access to all files on the local computer and network drives.

An individual FileIOPermissionAccess value can be checked for using a bitwise AND operation.

Example

[Visual Basic] 
' The AllFiles property gets or sets the permitted access to all files.
' The AllLocalFiles property gets or sets the permitted access to all local files.
Private Function AllFilesDemo() As Boolean
    Try
        Console.WriteLine("********************************************************" & ControlChars.Lf)

        Dim fileIOPerm1 As FileIOPermission
        Console.WriteLine("Creating a FileIOPermission and adding read access for all files")
        fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\Examples\Test\TestFile.txt")
        fileIOPerm1.AllFiles = FileIOPermissionAccess.Read
        Console.WriteLine("AllFiles access = " & fileIOPerm1.AllFiles.ToString())
        Console.WriteLine("Adding AllAccess rights for local files.")
        fileIOPerm1.AllLocalFiles = FileIOPermissionAccess.AllAccess
        Console.WriteLine("AllLocalFiles access = " & fileIOPerm1.AllLocalFiles.ToString())

    Catch e As ArgumentException
        Console.WriteLine(e.ToString())
        Return False
    End Try

    Return True
End Function 'AllFilesDemo


[C#] 
// The AllFiles property gets or sets the permitted access to all files.
// The AllLocalFiles property gets or sets the permitted access to all local files.
    private bool AllFilesDemo()
    {
        try
        {
            Console.WriteLine("********************************************************\n");

            FileIOPermission fileIOPerm1;
            Console.WriteLine("Creating a FileIOPermission and adding read access for all files");
            fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\\Examples\\Test\\TestFile.txt");
            fileIOPerm1.AllFiles = FileIOPermissionAccess.Read;
            Console.WriteLine("AllFiles access = " + fileIOPerm1.AllFiles);
            Console.WriteLine("Adding AllAccess rights for local files.");
            fileIOPerm1.AllLocalFiles = FileIOPermissionAccess.AllAccess;
            Console.WriteLine("AllLocalFiles access = " + fileIOPerm1.AllLocalFiles);

        }
        catch (ArgumentException e)
        {
            Console.WriteLine(e);
            return false;
        }

        return true;        
    }

[C++] 
// The AllFiles property gets or sets the permitted access to all files.
// The AllLocalFiles property gets or sets the permitted access to all local files.
private:
bool AllFilesDemo()
{
    try
    {
        Console::WriteLine(S"********************************************************\n");

        FileIOPermission* fileIOPerm1;
        Console::WriteLine(S"Creating a FileIOPermission and adding read access for all files");
        fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess::AllAccess, S"C:\\Examples\\Test\\TestFile.txt");
        fileIOPerm1->AllFiles = FileIOPermissionAccess::Read;
        Console::WriteLine(S"AllFiles access = {0}", __box(fileIOPerm1->AllFiles));
        Console::WriteLine(S"Adding AllAccess rights for local files.");
        fileIOPerm1->AllLocalFiles = FileIOPermissionAccess::AllAccess;
        Console::WriteLine(S"AllLocalFiles access = {0}", __box(fileIOPerm1->AllLocalFiles));

    }
    catch (ArgumentException* e)
    {
        Console::WriteLine(e);
        return false;
    }

    return true;        
}

[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

See Also

FileIOPermission Class | FileIOPermission Members | System.Security.Permissions Namespace

Show:
© 2014 Microsoft