VB.Net by API/System.Security.Permissions/EnvironmentPermission — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:50, 26 мая 2010

New EnvironmentPermission

   
Imports System.Security.Principal
Imports System.Security.Permissions
Imports System.IO

public class MainClass
   Shared Sub Main()
        Dim oEp As EnvironmentPermission = New EnvironmentPermission(EnvironmentPermissionAccess.Read, "Temp")
        Dim sEv As String
        oEp.Assert()
        Try
            sEv = Environment.GetEnvironmentVariable("Temp")
            Console.WriteLine("Assert was a success")
        Catch objA As System.Exception
            Console.WriteLine("Assert failed")
        End Try
        System.Security.CodeAccessPermission.RevertAssert()
        oEp.Deny()
        Try
            sEv = Environment.GetEnvironmentVariable("Temp")
            Console.WriteLine("Deny was a success")
        Catch objA As System.Exception
            Console.WriteLine("Deny failed")
        End Try
        Console.WriteLine(oEp.ToString)
   End Sub
End Class