![[C#] How to Encrypt a File in C#](https://csharpcanban.com/wp-content/uploads/2019/03/How-to-Encrypt-a-File-in-C-e1551618312605.jpg)
In this article csharpcanban.com will guide you How to Encrypt a File in C#, with examples and Demo code, you can download for use.
The Encrypt method encrypts a file so that only the account used to encrypt the file can decrypt
it.
string fileName = @"C:FileToEncrypt.txt"; FileInfo filetodecrypt = new FileInfo(fileName); filetodecrypt .Encrypt(); filetodecrypt .Decrypt();