Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FileDialogPermissionAccess Enumeration

Specifies the type of access to files allowed through the file dialog.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

[Visual Basic]
<Flags>
<Serializable>
Public Enum FileDialogPermissionAccess
[C#]
[Flags]
[Serializable]
public enum FileDialogPermissionAccess
[C++]
[Flags]
[Serializable]
__value public enum FileDialogPermissionAccess
[JScript]
public
   Flags
 Serializable
enum FileDialogPermissionAccess

Members

Member name Description Value
None No access to files through the file dialog. 0
Open Ability to open files through the file dialog. 1
OpenSave Ability to open and save files through the file dialog. 3
Save Ability to save files through the file dialog. 2

Example

[Visual Basic] 
' This class generates FileDialogPermission objects using FileDialogPermissionAccess enumeration values.

Imports System
Imports System.Security
Imports System.Security.Permissions
Imports Microsoft.VisualBasic

Public Class FileDialogGenerator


    Private myFileDialog As FileDialogPermissionAccess() = _
        {FileDialogPermissionAccess.None, _
        FileDialogPermissionAccess.Open, _
        FileDialogPermissionAccess.OpenSave, _
        FileDialogPermissionAccess.Save}

    Private fileDialogIndex As Integer = 0


    Public Sub New()
        ResetIndex()
    End Sub 'New


    Public Sub ResetIndex()
        fileDialogIndex = 0
    End Sub 'ResetIndex

    ' Create a FileDialogPermission.
    Public Function CreateFileDialog(ByRef fileDialogPerm As FileDialogPermission, ByRef fileDialog As FileDialogPermissionAccess) As Boolean

        If fileDialogIndex >= myFileDialog.Length Then
            fileDialogPerm = New FileDialogPermission(PermissionState.None)
            fileDialog = FileDialogPermissionAccess.None
            Return False
        End If
        fileDialog = myFileDialog(fileDialogIndex)
        fileDialogIndex = fileDialogIndex + 1
        Try
            fileDialogPerm = New FileDialogPermission(fileDialog)
            Return True
        Catch e As Exception
            Console.WriteLine(("Cannot create FileDialogPermission: " & fileDialog & " " & e.ToString()))
            fileDialogPerm = New FileDialogPermission(PermissionState.None)
            fileDialog = FileDialogPermissionAccess.None
            Return True
        End Try
    End Function 'CreateFileDialog
End Class 'FileDialogGenerator 
' End of FileDialogGenerator.

[C#] 
// This class generates FileDialogPermission objects using FileDialogPermissionAccess enumeration values.

using System;
using System.Security; 
using System.Security.Permissions; 


public  class FileDialogGenerator
{


    private FileDialogPermissionAccess[] myFileDialog = 
    {
        FileDialogPermissionAccess.None,
        FileDialogPermissionAccess.Open, 
        FileDialogPermissionAccess.OpenSave, 
        FileDialogPermissionAccess.Save};

    private int fileDialogIndex = 0;

    public FileDialogGenerator()
    {
        ResetIndex();
    }

    public void ResetIndex()
    {
        fileDialogIndex = 0;
    }
    // Create a FileDialogPermission.
    public bool CreateFileDialog(out FileDialogPermission fileDialogPerm, 
        out FileDialogPermissionAccess fileDialog)
    {

        if(fileDialogIndex >= myFileDialog.Length) 
        {
            fileDialogPerm = new FileDialogPermission(PermissionState.None);
            fileDialog=FileDialogPermissionAccess.None;
            return false;
        }
        fileDialog = myFileDialog[fileDialogIndex++];
        try
        {
            fileDialogPerm = new FileDialogPermission(fileDialog);
            return true;
        } 
        catch(Exception e)
        {
            Console.WriteLine("Cannot create FileDialogPermission: " + fileDialog +" "+e);
            fileDialogPerm = new FileDialogPermission(PermissionState.None);
            fileDialog=FileDialogPermissionAccess.None;
            return true;
        }
    }

} // End of FileDialogGenerator.

[C++] 
// This class generates FileDialogPermission objects using FileDialogPermissionAccess enumeration values.

#using <mscorlib.dll>
using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Security; 
using namespace System::Security::Permissions; 


public  __gc class FileDialogGenerator
{
private:
   FileDialogPermissionAccess myFileDialog[];
   int fileDialogIndex;

public:
   FileDialogGenerator()
   {
      ResetIndex();
      FileDialogPermissionAccess tempFileDialog[] = {
         FileDialogPermissionAccess::None,
         FileDialogPermissionAccess::Open, 
         FileDialogPermissionAccess::OpenSave, 
         FileDialogPermissionAccess::Save};
      myFileDialog = tempFileDialog;
   }

   void ResetIndex()
   {
      fileDialogIndex = 0;
   }
   // Create a FileDialogPermission.
   bool CreateFileDialog([Out]FileDialogPermission** fileDialogPerm, 
      [Out]FileDialogPermissionAccess* fileDialog)
   {

      if(fileDialogIndex >= myFileDialog->Length) 
      {
         *fileDialogPerm = new FileDialogPermission(PermissionState::None);
         *fileDialog=FileDialogPermissionAccess::None;
         return false;
      }
      *fileDialog = myFileDialog[fileDialogIndex++];
      try
      {
         *fileDialogPerm = new FileDialogPermission(*fileDialog);
         return true;
      } 
      catch(Exception* e)
      {
         Console::WriteLine(S"Cannot create FileDialogPermission: {0} {1}", __box(*fileDialog), e);
         *fileDialogPerm = new FileDialogPermission(PermissionState::None);
         *fileDialog=FileDialogPermissionAccess::None;
         return true;
      }
   }
}; // End of FileDialogGenerator.

[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

Namespace: System.Security.Permissions

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

System.Security.Permissions Namespace | FileDialogPermission | FileDialogPermissionAttribute

Show:
© 2015 Microsoft