Assembly asm = Assembly.GetExecutingAssembly();<br /> string rootname = asm.GetName().Name.ToString();<br /> Stream strem = asm.GetManifestResourceStream(rootname + ".Resources." + "client.exe");<br /> <br /> BinaryReader br = new BinaryReader(strem);<br /> FileStream fs = new FileStream("client.exe",FileMode.OpenOrCreate);<br /> BinaryWriter bw = new BinaryWriter(fs);<br /> byte[] ba = new byte[strem.Length];<br /> strem.Read(ba, 0, ba.Length);<br /> bw.Write(ba);<br /> br.Close();<br /> bw.Close();<br /> <br /> Process p = new Process();<br /> p.StartInfo.FileName = "client.exe";<br /> p.Start();
//Get the current assembly<br /> Assembly assembly = Assembly.GetExecutingAssembly();<br /> <br /> //Get the assembly's root name<br /> string rootName = assembly.GetName().Name;<br /> <br /> //Get the resource stream<br /> Stream resourceStream = assembly.GetManifestResourceStream(rootName + ".Resources." + "client.exe");<br /> <br /> //Verify the internal exe exists<br /> if (resourceStream == null)<br /> return;<br /> <br /> //Read the raw bytes of the resource<br /> byte[] resourcesBuffer = new byte[resourceStream.Length];<br /> <br /> resourceStream.Read(resourcesBuffer, 0, resourcesBuffer.Length);<br /> resourceStream.Close();<br /> <br /> //Load the bytes as an assembly<br /> Assembly exeAssembly = Assembly.Load(resourcesBuffer);<br /> <br /> //Execute the assembly<br /> exeAssembly.EntryPoint.Invoke(null, null); //no parameters
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)