In this tutorial I will guide you How to Encrypt/Decrypta File in C#, with examples and Demo code, you can download for use.
The Decrypt method decrypts an encrypted file. Only account that has encrypted a file can decrypt a file.
The Encrypt method encrypts a file so that only the account used to encrypt the file can decrypt it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class Program { static void Main(string[] args) { string fileName = @"E:file.txt"; FileInfo filetodecrypt = new FileInfo(fileName); filetodecrypt.Encrypt(); //Encrypt filetodecrypt.Decrypt(); //Decrypt Console.ReadLine(); } } |
After file encyrpted output:
After file Decrypt output: