VB.Net by API/System.Security.Permissions/FileIOPermission

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

New FileIOPermission

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

public class MainClass
   Shared Sub Main()
        Dim oFp As FileIOPermission = New FileIOPermission(FileIOPermissionAccess.Write, "d:\test.txt")
        oFp.Assert()
        Try
            Dim objWriter As New IO.StreamWriter(File.Open("d:\test.txt", IO.FileMode.Open))
            objWriter.WriteLine("Hi there!")
            objWriter.Flush()
            objWriter.Close()
            objWriter = Nothing
        Catch objA As System.Exception
            Console.WriteLine(objA.Message)
        End Try
   End Sub
End Class