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
|