Environment Permissions Demo : Security « Security « VB.Net






Environment Permissions Demo

Environment Permissions Demo
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



           
       








Related examples in the same category

1.Registry Permissions Demo
2.Check File IO Permission