Hi,
i am developing a little password program, which encrypts the file and password protects it.
when one tries to open the password protected file, a password dialog pops up. if correct password is entered, it runs the file. The problem is that i don't want to extract the contents of the file and save it in the windows temp folder. Instead, i want to load the file from the memory and run it.
here is a sample of my code:
----------------------------------------------------------------------------------------------
System.IO.MemoryStream ms=new MemoryStream();
BinaryReader r= new BinaryReader(File.Open(filename,FileMode.Open),System.Text.Encoding.Default);
byte[] bt=new byte[r.BaseStream.Length];
int ctr=0;
while(r.PeekChar() != -1)
{
bt[ctr]=r.ReadByte();
ctr++;
}
r.Close();
MemoryStream m=new MemoryStream();
m.Write(bt,0,bt.Length);
File.Delete(filename);
w.Flush();
w.Close();
----------------------------------------------------------------------------------------------
I am able to write the file into the memory, but how do i make it run from there? Because i am using a byte[] array,i cannot use System.Diagnostics.Process.Start() method to run the byte[]. Please suggest a way where i can load the file into the memory and run it from the memory, without having to save it anywhere on the harddrive.
Answers
Know the answer? Post it. Somebody with the same question will find it here.