C# FileInfo Encrypt
Description
FileInfo Encrypt
Encrypts a file so that only the account
used to encrypt the file can decrypt it.
Syntax
FileInfo.Encrypt
has the following syntax.
[ComVisibleAttribute(false)]
public void Encrypt()
Returns
FileInfo.Encrypt
method returns
Example
The following code example uses the Encrypt method and the Decrypt method to encrypt a file and then decrypt it.
using System;// w ww .ja v a 2s. c om
using System.IO;
using System.Security.AccessControl;
class FileExample
{
public static void Main()
{
string FileName = @"c:\MyTest.txt";
FileInfo fInfo = new FileInfo(FileName);
if (!fInfo.Exists)
{
fInfo.Create();
}
fInfo.Encrypt();
fInfo.Decrypt();
}
}