Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding an external executable inside a C# program

How do I embed an external executable inside my C# Windows Forms application?

Edit: I need to embed it because it's an external free console application (made in C++) from which I read the output values to use in my program. It would be nice and more professional to have it embedded.

Second reason is a requirement to embed a Flash projector file inside a .NET application.

like image 568
Josh Avatar asked Apr 28 '09 15:04

Josh


1 Answers

Simplest way, leading on from what Will said:

  1. Add the .exe using Resources.resx
  2. Code this:

    string path = Path.Combine(Path.GetTempPath(), "tempfile.exe");   File.WriteAllBytes(path, MyNamespace.Properties.Resources.MyExecutable); Process.Start(path); 
like image 133
dav_i Avatar answered Oct 17 '22 07:10

dav_i