Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Code 1 : This code extract and run client.exe

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();

-----------------------------------------------------------------------
Code 2 : This code dont work !

            //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



i want to run client.exe in resources without extract how can i do !!!!!
Posted

1 solution

he heyy pls answer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

'Bumping' is rude - please do not do it!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900