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#.
Reader Level:

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);

Login to add your contents and source code to this article
post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.