C# File Encrypt

Description

File Encrypt Encrypts a file so that only the account used to encrypt the file can decrypt it.

Syntax

File.Encrypt has the following syntax.


public static void Encrypt(
  string path
)

Parameters

File.Encrypt has the following parameters.

  • path - A path that describes a file to encrypt.

Returns

File.Encrypt method returns

Example

The following code example uses the Encrypt method and the Decrypt method to encrypt and then decrypt a file.


using System;// w ww  . j  av a  2s . co m
using System.IO;
using System.Security.AccessControl;

class FileExample
{
        public static void Main()
        {
            string FileName = "test.xml";
            File.Encrypt(FileName);
            File.Decrypt(FileName);
        }
}




















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter