i was reading up on it and i seen how to open a pic from the embedded resources but i cant seem to find anything on how to execute a .exe file that is a embedded resource
I gues xbox.exe is not written in managed code, so the only way to run it from your app is to embed it first and at runtime you'll copy from the resource to Windows TMP and run it from there.. then you delete it...
I gues xbox.exe is not written in managed code, so the only way to run it from your app is to embed it first and at runtime you'll copy from the resource to Windows TMP and run it from there.. then you delete it...
Do you have any tutorials on this or can you contact me on msn to help me if you have time . THANKS ALOT
As suggested by some other user, you need to copy that embedded resource to a temporary location (Windows Temp for eg). To create a file out of the embedded resource, you will use System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream (<the name of the exe resource). This gives you a System.IO.Stream object tha you read and write the content to a System.IO.FileStream object.
Executing Exe
darthziv
using System.Diagnostics;
Process proc = new Process();
proc.StartInfo.FileName = "app.exe";
proc.Start();
For more details search the MSDN for Process class.
jonas k
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "Full Path to EXE";
process.Start();
Michael Morris
You call it like this:
RunEmbededExe("unpackedXBOXv2.exe");
Neil Janabi
MJC2006
rekasnuh
When you put app.exe i put the filename of the app in the solution explorer but i get a error that says system cant find the file.
look here: http://yourserversolution.com/pro.JPG
Mikhail Ryzhinskiy
Here it is:
public static void RunEmbededExe(string exeName) { int read = 0; byte[] buffer = new byte[2048]; Assembly asm = Assembly.GetExecutingAssembly(); using (Stream stream = asm.GetManifestResourceStream(asm.GetName().Name + "." + exeName)) { using (FileStream fs = new FileStream(Application.StartupPath + "\\" + exeName, FileMode.Create, FileAccess.Write)) { using (BinaryWriter bw = new BinaryWriter(fs)) { while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { bw.Write(buffer, 0, read); bw.Flush(); } } } } buffer = null; const int ERROR_FILE_NOT_FOUND = 2; const int ERROR_ACCESS_DENIED = 5; Process proc = new Process(); try { proc.StartInfo.FileName = Application.StartupPath + "\\" + exeName; proc.StartInfo.CreateNoWindow = false; proc.Start(); proc.WaitForExit(); } catch (Win32Exception ex) { if (ex.NativeErrorCode == ERROR_FILE_NOT_FOUND) { MessageBox.Show(ex.Message + ". Check the path."); } else if (ex.NativeErrorCode == ERROR_ACCESS_DENIED) { MessageBox.Show(ex.Message + ".\n You do not have permission to run this file."); } } }Malleswar
Halil_developer
Chris Fink
masmith
sabo
Do you have any tutorials on this or can you contact me on msn to help me if you have time . THANKS ALOT
EWoodruff
CalinMac
As suggested by some other user, you need to copy that embedded resource to a temporary location (Windows Temp for eg). To create a file out of the embedded resource, you will use System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream (<the name of the exe resource). This gives you a System.IO.Stream object tha you read and write the content to a System.IO.FileStream object.