本文整理汇总了VB.NET中System.IO.FileInfo.Decrypt方法的典型用法代码示例。如果您正苦于以下问题:VB.NET FileInfo.Decrypt方法的具体用法?VB.NET FileInfo.Decrypt怎么用?VB.NET FileInfo.Decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.Decrypt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: FileExample
' 导入命名空间
Imports System.IO
Imports System.Security.AccessControl
Module FileExample
Sub Main()
Try
Dim FileName As String = "c:\MyTest.txt"
Console.WriteLine("Encrypt " + FileName)
' Encrypt the file.
AddEncryption(FileName)
Console.WriteLine("Decrypt " + FileName)
' Decrypt the file.
RemoveEncryption(FileName)
Console.WriteLine("Done")
Catch e As Exception
Console.WriteLine(e)
End Try
End Sub
Sub AddEncryption(ByVal FileName As String)
' Create a new FileInfo object.
Dim fInfo As New FileInfo(FileName)
If fInfo.Exists = False Then
fInfo.Create()
End If
' Add encryption.
fInfo.Encrypt()
End Sub
Sub RemoveEncryption(ByVal FileName As String)
' Create a new FileInfo object.
Dim fInfo As New FileInfo(FileName)
If fInfo.Exists = False Then
fInfo.Create()
End If
' Remove encryption.
fInfo.Decrypt()
End Sub
End Module
'This code produces output similar to the following;
'results may vary based on the computer/file structure/etc.:
'
'Encrypt c:\MyTest.txt
'Decrypt c:\MyTest.txt
'Done