Encrypt and Decrypt a file in CSharp
Description
The following code shows how to encrypt and Decrypt a file.
Example
//from w ww . j a va 2 s .c o m
using System;
using System.IO;
using System.Security.AccessControl;
class FileExample
{
public static void Main()
{
string FileName = "test.xml";
AddEncryption(FileName);
Console.WriteLine("Decrypt " + FileName);
RemoveEncryption(FileName);
}
public static void AddEncryption(string FileName)
{
File.Encrypt(FileName);
}
public static void RemoveEncryption(string FileName)
{
File.Decrypt(FileName);
}
}