Reader Level:
ARTICLE

Encrypt a File in C#

Posted by Dinesh Beniwal Articles | Files, Directory, IO August 09, 2012
In this article we will discuss about how to Encrypt a File in C#.
  • 0
  • 0
  • 12140

The File class provides the Encrypt and the Decrypt methods to restrict other users to open and read a file. 

Encrypt a File in C#

The Encrypt method encrypts a file so that only the account used to encrypt the file can decrypt it.

string fileName = @"c:\temp\Mahesh.txt";
File
.Encrypt(fileName);

Decrypt a File in C#

The Decrypt method decrypts an encrypted file. Only account that has encrypted a file can decrypt a file.

string fileName = @"c:\temp\Mahesh.txt";
File
.Decrypt(fileName);

COMMENT USING

Trending up