如果我将一个可执行文件作为资源嵌入到进程中,并且希望直接从内存中运行该进程而不将其放在磁盘上。
static void Main()
{
const string pathOfExecutable = @"C:\WINDOWS\system32\notepad.exe"; //size = 67KB
// read the bytes from the application EXE file
FileStream fs = new FileStream(pathOfExecutable, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] byteArray = br.ReadBytes(Convert.ToInt32(fs.Length));
fs.Close();
br.Close();
//Process.Start(byteArray) //Cannot use this, any other alternative?
}