Export (0) Print
Expand All
Expand Minimize

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.

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

[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[FlagsAttribute] 
public enum FileDialogPermissionAccess
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute FlagsAttribute() */ 
public enum FileDialogPermissionAccess
SerializableAttribute 
ComVisibleAttribute(true) 
FlagsAttribute 
public enum FileDialogPermissionAccess

 Member nameDescription
NoneNo access to files through the file dialog. 
OpenAbility to open files through the file dialog. 
OpenSaveAbility to open and save files through the file dialog. 
SaveAbility to save files through the file dialog. 

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

}

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft