Freigeben über


FileDialogPermissionAccess-Enumeration

Gibt den Typ des über das Dateidialogfeld möglichen Zugriffs auf Dateien an.

Diese Enumeration verfügt über ein FlagsAttribute -Attribut, das die bitweise Kombination der Memberwerte zulässt.

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

Syntax

'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
<FlagsAttribute> _
Public Enumeration FileDialogPermissionAccess
'Usage
Dim instance As FileDialogPermissionAccess
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[FlagsAttribute] 
public enum FileDialogPermissionAccess
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[FlagsAttribute] 
public enum class FileDialogPermissionAccess
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute FlagsAttribute() */ 
public enum FileDialogPermissionAccess
SerializableAttribute 
ComVisibleAttribute(true) 
FlagsAttribute 
public enum FileDialogPermissionAccess

Member

  Membername Beschreibung
None Kein Zugriff auf Dateien über das Dateidialogfeld. 
Open Die Möglichkeit, Dateien über das Dateidialogfeld zu öffnen. 
OpenSave Die Möglichkeit zum Öffnen und Speichern von Dateien über das Dateidialogfeld. 
Save Die Möglichkeit, Dateien über das Dateidialogfeld zu speichern. 

Beispiel

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
End Class
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;
        }
    }

}
using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
public ref class FileDialogGenerator
{
private:
   array<FileDialogPermissionAccess>^myFileDialog;
   int fileDialogIndex;

public:
   FileDialogGenerator()
   {
      ResetIndex();
      array<FileDialogPermissionAccess>^ tempFileDialog = {FileDialogPermissionAccess::None,FileDialogPermissionAccess::Open,FileDialogPermissionAccess::OpenSave,FileDialogPermissionAccess::Save};
      myFileDialog = tempFileDialog;
   }

   void ResetIndex()
   {
      fileDialogIndex = 0;
   }


   // Create a FileDialogPermission.
   bool CreateFileDialog( [Out]interior_ptr<FileDialogPermission^> fileDialogPerm, [Out]FileDialogPermissionAccess * fileDialog )
   {
      if ( fileDialogIndex >= myFileDialog->Length )
      {
          *fileDialogPerm = gcnew FileDialogPermission( PermissionState::None );
          *fileDialog = FileDialogPermissionAccess::None;
         return false;
      }

       *fileDialog = myFileDialog[ fileDialogIndex++ ];
      try
      {
          *fileDialogPerm = gcnew FileDialogPermission(  *fileDialog );
         return true;
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "Cannot create FileDialogPermission: {0} {1}",  *fileDialog, e );
          *fileDialogPerm = gcnew FileDialogPermission( PermissionState::None );
          *fileDialog = FileDialogPermissionAccess::None;
         return true;
      }

   }

};

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

System.Security.Permissions-Namespace
FileDialogPermission-Klasse
FileDialogPermissionAttribute