本文整理汇总了VB.NET中System.Security.Permissions.FileIOPermission类的典型用法代码示例。如果您正苦于以下问题:VB.NET FileIOPermission类的具体用法?VB.NET FileIOPermission怎么用?VB.NET FileIOPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileIOPermission类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: FileIOPermission
Dim f As New FileIOPermission(PermissionState.None)
f.AllLocalFiles = FileIOPermissionAccess.Read
Try
f.Demand()
Catch s As SecurityException
Console.WriteLine(s.Message)
End Try
示例2: FileIOPermission
Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, "C:\test_r")
f2.AddPathList(FileIOPermissionAccess.Write Or FileIOPermissionAccess.Read, "C:\example\out.txt")
Try
f2.Demand()
Catch s As SecurityException
Console.WriteLine(s.Message)
End Try
示例3: 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