Main.EXE ve Child.EXE isminde iki adet EXE dosyamız olduğunu düşünelim.
Senaryomuza göre Main.EXE'den Child.EXE i oluşturup çalıştıracağız.
Project -> Add Extisting Item diyerek Child.EXE yi projenize ekleyin.
Solution Explorer penceresinde Child.EXE yi seçin.
Properties penceresinde Build Action özelliğine Embeded Resource atayın.
Main.EXE de istediğiniz bir yerde aşağıdaki kodu çalıştırın :
System.Reflection.Assembly asm;
asm = System.Reflection.Assembly.GetExecutingAssembly();
string resourceName = asm.GetName().Name + ".Child.exe";
System.IO.Stream stream = asm.GetManifestResourceStream(resourceName);
byte
[] buffer = new byte[stream.Length];
int bufferSize = Convert.ToInt32(stream.Length);
stream.Read(buffer, 0, bufferSize);
string tempFileFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
string tempFilePath = System.IO.Path.Combine(tempFileFolder, "Child.exe");
System.IO.FileStream fs = new System.IO.FileStream(tempFilePath, System.IO.FileMode.Create);
fs.Write(buffer, 0, bufferSize);
fs.Close();
System.Diagnostics.Process.Start(tempFilePath);
Doğal olarak Childe.EXE çalışırken bir güvenlik uyarı alıyorsunuz.