Encrypt and Decrypt a File in asp.Net with C#

This article explains how to Encrypt and Decrypt a file in C#.
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\vepsh.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\vepsh.txt";
File.Decrypt(fileName);
 
Ashwani
Ashwani

This is a short biography of the post author. Maecenas nec odio et ante tincidunt tempus donec vitae sapien ut libero venenatis faucibus nullam quis ante maecenas nec odio et ante tincidunt tempus donec.

2 comments: