Net Encryption Library
EncryptFile(EncryptionProvider,String,String,String) Method
Example 






KellermanSoftware.NetEncryptionLibrary Namespace > Encryption Class > EncryptFile Method : EncryptFile(EncryptionProvider,String,String,String) Method
The encryption algorithm to use
The encryption password
The file to encrypt
The output encrypted file
Encrypt a text or binary file using the selected encryption provider. The file will be base64 encoded.
Syntax
'Declaration
 
Public Overloads Function EncryptFile( _
   ByVal encryptionType As EncryptionProvider, _
   ByVal key As System.String, _
   ByVal inputFilePath As System.String, _
   ByVal outputFilePath As System.String _
) As System.Boolean
'Usage
 
Dim instance As Encryption
Dim encryptionType As EncryptionProvider
Dim key As System.String
Dim inputFilePath As System.String
Dim outputFilePath As System.String
Dim value As System.Boolean
 
value = instance.EncryptFile(encryptionType, key, inputFilePath, outputFilePath)
public System.bool EncryptFile( 
   EncryptionProvider encryptionType,
   System.string key,
   System.string inputFilePath,
   System.string outputFilePath
)
public function EncryptFile( 
    encryptionType: EncryptionProvider;
    key: System.String;
    inputFilePath: System.String;
    outputFilePath: System.String
): System.Boolean; 
public function EncryptFile( 
   encryptionType : EncryptionProvider,
   key : System.String,
   inputFilePath : System.String,
   outputFilePath : System.String
) : System.boolean;
public: System.bool EncryptFile( 
   EncryptionProvider encryptionType,
   System.string* key,
   System.string* inputFilePath,
   System.string* outputFilePath
) 
public:
System.bool EncryptFile( 
   EncryptionProvider encryptionType,
   System.String^ key,
   System.String^ inputFilePath,
   System.String^ outputFilePath
) 

Parameters

encryptionType
The encryption algorithm to use
key
The encryption password
inputFilePath
The file to encrypt
outputFilePath
The output encrypted file
Example
Encryption encryption = new Encryption(); //Trial Mode
//Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
File.WriteAllText("input.txt", "This is a test");
 
encryption.EncryptFile(EncryptionProvider.Rijndael, "My Password", "input.txt", "encrypted.txt");
 
bool decryptedSucessfully = encryption.DecryptFile(EncryptionProvider.Rijndael, "My Password", "encrypted.txt", "decrypted.txt");
 
Console.WriteLine("Decrypted successfully: {0}", decryptedSucessfully);
Dim encryption As New Encryption() 'Trial Mode
'Dim encryption As New Encryption("place user name here", "place license key here") 'License Mode
 
File.WriteAllText("input.txt", "This is a test")
 
encryption.EncryptFile(EncryptionProvider.Rijndael, "My Password", "input.txt", "encrypted.txt")
 
Dim decryptedSucessfully As Boolean = encryption.DecryptFile(EncryptionProvider.Rijndael, "My Password", "encrypted.txt", "decrypted.txt")
 
Console.WriteLine("Decrypted successfully: {0}", decryptedSucessfully)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Encryption Class
Encryption Members
Overload List