How can I execute a program that is in a MemoryStream so I don't have to save it first to the harddisk. The file may not be saved temperally to the harddisk. The program has to be 100% functional from in memory.
static string strTemplate = "MyAPP.SOMEprogram.exe";
byte[] template;
int len = 0;
Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream = assembly.GetManifestResourceStream(strTemplate))
{
len = (int)stream.Length;
BinaryReader reader = new BinaryReader(stream);
template = reader.ReadBytes(len);
}
MemoryStream ms = new MemoryStream(template, true);
Now all 100% working program in MemoryStream (on RAM), can i execute that program? Many Thanks
I cannot think of an obviouse way to do this. The closest I can think of is using a RAM disc - you will have no hard disc access (besides maybe paging) but this is still very different from what you are asking.
Just to note, I am talking about running arbitrary programs, not loading managed assemblies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With