本文整理匯總了VB.NET中System.IO.FileInfo.Encrypt方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET FileInfo.Encrypt方法的具體用法?VB.NET FileInfo.Encrypt怎麽用?VB.NET FileInfo.Encrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.Encrypt方法的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