FileIOPermission.Union メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As FileIOPermission Dim other As IPermission Dim returnValue As IPermission returnValue = instance.Union(other)
戻り値
現在のアクセス許可と指定したアクセス許可の和集合を表す新しいアクセス許可。


Union を呼び出すと、現在のアクセス許可と指定したアクセス許可の両方が表す操作をすべて表すアクセス許可が作成されます。いずれかのアクセス許可を要求し、その要求が満たされた場合、両者の和集合を表すアクセス許可に対する要求も満たされます。

Private Function UnionDemo() As Boolean Dim returnValue As Boolean = True Dim fileIO1 As String = "" Dim fileIO2 As String = "" Dim fileIOPerm1, fileIOPerm2 As FileIOPermission Dim fileIOPerm3 As IPermission Dim fileIOGen1 As New FileIOGenerator() Dim fileIOGen2 As New FileIOGenerator() fileIOGen1.ResetIndex() While fileIOGen1.CreateFilePath(fileIO1) If fileIO1 = "" Then fileIOPerm1 = New FileIOPermission(PermissionState.None) Else fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO1) End If Console.WriteLine("**********************************************************" & ControlChars.Lf) fileIOGen2.ResetIndex() While fileIOGen2.CreateFilePath(fileIO2) Try If fileIO2 = "" Then fileIOPerm2 = New FileIOPermission(PermissionState.None) Else fileIOPerm2 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO2) End If Dim firstPermission As String = IIf(fileIO1 = "" Or fileIO1 Is Nothing, "null", fileIO1) Dim secondPermission As String = IIf(fileIO2 = "" Or fileIO2 Is Nothing, "null", fileIO2) fileIOPerm3 = CType(fileIOPerm1.Union(fileIOPerm2), FileIOPermission) fileIOPerm3 = fileIOPerm1.Union(fileIOPerm2) If fileIOPerm3 Is Nothing Then Console.WriteLine(("The union of " & firstPermission & " and " & secondPermission & " is null.")) Else Console.WriteLine(("The union of " & firstPermission & " and " & secondPermission & " = " & ControlChars.Lf & ControlChars.Tab & CType(fileIOPerm3, FileIOPermission).GetPathList(FileIOPermissionAccess.Read)(0))) End If Catch e As Exception Console.WriteLine(("An exception was thrown for union " & e.ToString())) returnValue = False End Try ContinueWhile2: End While ContinueWhile1: End While Return returnValue End Function 'UnionDemo
private bool UnionDemo() { bool returnValue = true; string fileIO1, fileIO2; FileIOPermission fileIOPerm1, fileIOPerm2; IPermission fileIOPerm3; FileIOGenerator fileIOGen1 = new FileIOGenerator(); FileIOGenerator fileIOGen2 = new FileIOGenerator(); fileIOGen1.ResetIndex(); while (fileIOGen1.CreateFilePath( out fileIO1 )) { if (fileIO1 == "") fileIOPerm1 = new FileIOPermission(PermissionState.None); else fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO1); if (fileIO1 == null) continue; Console.WriteLine("**********************************************************\n"); fileIOGen2.ResetIndex(); while (fileIOGen2.CreateFilePath( out fileIO2 )) { if (fileIO2 == "") fileIOPerm2 = new FileIOPermission(PermissionState.None); else fileIOPerm2 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO2); try { string firstPermission = fileIO1 == "" | fileIO1 == null ? "null" : fileIO1; string secondPermission = fileIO2 == "" | fileIO2 == null ? "null" : fileIO2; fileIOPerm3 = (FileIOPermission)fileIOPerm1.Union(fileIOPerm2); fileIOPerm3 = fileIOPerm1.Union(fileIOPerm2); if (fileIOPerm3 == null) { Console.WriteLine("The union of " + firstPermission + " and " + secondPermission + " is null."); } else { Console.WriteLine("The union of " + firstPermission + " and " + secondPermission + " = \n\t" + ((FileIOPermission)fileIOPerm3).GetPathList(FileIOPermissionAccess.Read)[0]); } } catch (Exception e) { Console.WriteLine("An exception was thrown for union " + e); returnValue = false; } } } return returnValue; }
bool UnionDemo() { bool returnValue = true; String^ fileIO1; String^ fileIO2; FileIOPermission^ fileIOPerm1; FileIOPermission^ fileIOPerm2; IPermission^ fileIOPerm3; FileIOGenerator^ fileIOGen1 = gcnew FileIOGenerator; FileIOGenerator^ fileIOGen2 = gcnew FileIOGenerator; fileIOGen1->ResetIndex(); while ( fileIOGen1->CreateFilePath( &fileIO1 ) ) { if (fileIO1 == "") fileIOPerm1 = gcnew FileIOPermission(PermissionState::None); else fileIOPerm1 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO1); Console::WriteLine( "**********************************************************\n" ); fileIOGen2->ResetIndex(); while ( fileIOGen2->CreateFilePath( &fileIO2 ) ) { if (fileIO2 == "") fileIOPerm2 = gcnew FileIOPermission(PermissionState::None); else fileIOPerm2 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO2); try { if ( fileIOPerm2 == nullptr ) continue; String^ firstPermission = fileIO1 == "" || fileIO1 == nullptr ? "null" : fileIO1; String^ secondPermission = fileIO2 == "" || fileIO2 == nullptr ? "null" : fileIO2; fileIOPerm3 = dynamic_cast<FileIOPermission^>(fileIOPerm1->Union( fileIOPerm2 )); fileIOPerm3 = fileIOPerm1->Union( fileIOPerm2 ); if ( fileIOPerm3 == nullptr ) { Console::WriteLine( "The union of {0} and {1} is null.", firstPermission, secondPermission ); } else { Console::WriteLine( "The union of {0} and {1} = \n\t{2}", firstPermission, secondPermission, (dynamic_cast<FileIOPermission^>(fileIOPerm3))->GetPathList( FileIOPermissionAccess::Read )[ 0 ] ); } } catch ( Exception^ e ) { Console::WriteLine( "An exception was thrown for union {0}", e ); returnValue = false; } } } return returnValue; }
// Union creates a new permission that is the union of the current // permission and the specified permission. private boolean UnionDemo() { boolean returnValue = true; String fileIO1[] = new String[1]; String fileIO2[] = new String[1]; FileIOPermission fileIOPerm1[] = new FileIOPermission[1]; FileIOPermission fileIOPerm2[] = new FileIOPermission[1]; IPermission fileIOPerm3; FileIOGenerator fileIOGen1 = new FileIOGenerator(); FileIOGenerator fileIOGen2 = new FileIOGenerator(); fileIOGen1.ResetIndex(); while(fileIOGen1.CreateFilePath(fileIOPerm1, fileIO1, FileIOPermissionAccess.Read)) { if (fileIO1[0] == null) { continue ; } Console.WriteLine("*****************************" + "*****************************\n"); fileIOGen2.ResetIndex(); while(fileIOGen2.CreateFilePath(fileIOPerm2, fileIO2, FileIOPermissionAccess.Read)) { try { if (fileIOPerm2[0] == null) { continue ; } String firstPermission = (fileIO1[0].equals("")== true | fileIO1[0] == null) ? "null" : fileIO1[0]; String secondPermission = (fileIO2[0].equals("") == true | fileIO2[0] == null) ? "null" : fileIO2[0]; fileIOPerm3 =((FileIOPermission)(fileIOPerm1[0]. Union(fileIOPerm2[0]))); fileIOPerm3 = fileIOPerm1[0].Union(fileIOPerm2[0]); if (fileIOPerm3 == null) { Console.WriteLine(("The union of " + firstPermission + " and " + secondPermission + " is null.")); } else { Console.WriteLine(("The union of " + firstPermission + " and " + secondPermission + " = \n\t" + ((FileIOPermission)(fileIOPerm3)). GetPathList(FileIOPermissionAccess.Read). get_Item( 0))); } } catch(System.Exception e) { Console.WriteLine(("An exception was " + "thrown for union " + e)); returnValue = false; } } } return returnValue ; } //UnionDemo

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- FileIOPermission.Union メソッドのページへのリンク