To Encrypt a file in unreadble formate use
using System.Security.Cryptography;
.......................................................................................
public void EncryptFile(string inputFile, string outputFile)
{
string password = @"Test123";
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
string cryptFile = outputFile;
FileStream fsCrypt = new FileStream(cryptFile, FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsCrypt,
RMCrypto.CreateEncryptor(key, key),
CryptoStreamMode.Write);
FileStream fsIn = new FileStream(inputFile, FileMode.Open);
int data;
while ((data = fsIn.ReadByte()) != -1)
cs.WriteByte((byte)data);
fsIn.Close();
cs.Close();
fsCrypt.Close();
}
......................................................................................
For Decrypt, Encrypted file use
public void DecryptFile(string inputFile, string outputFile)
{
{
string password = @"Test123";
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
FileStream fsCrypt = new FileStream(inputFile, FileMode.Open);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsCrypt,
RMCrypto.CreateDecryptor(key, key),
CryptoStreamMode.Read);
FileStream fsOut = new FileStream(outputFile, FileMode.Create);
int data;
while ((data = cs.ReadByte()) != -1)
fsOut.WriteByte((byte)data);
fsOut.Close();
cs.Close();
fsCrypt.Close();
}
}
Thursday, February 28, 2013
Tuesday, February 26, 2013
VS2010 Setup Project: Uninstalling the previous MSI
For creating update version of installed MSI do the Following Step in vs2010 Project
1 . Change version in assembly file of Project ( version have 4 octate Major.Minor.Build.Release)
2 . You have to change Major or Minor Octate.
3 . Change GUID also in assembly file.
These are the change which you have to make in Project file.
Now open property window of Setup Project and do the following Change.
1. Change the Major/ Minor Version. ( it automatically change Project id but remain Upgradation COde)
2. Set RemovePreviousVersion to True.
3. Set DetectNewerInstalledVersion to True
Compile Setup and install. Its Working !!
Subscribe to:
Posts (Atom)