windows - Embedding an external executable inside a C# program -
How can I embed an external executable inside my C # windows form application?
EDIT: I want to embed it because it is an external free console application (built in C ++). I read the output values for use in my program.
The second reason is the need to embed a flash projector file inside a .net application.
Here are some sample codes that will roughly complete, checking error from any type of zero . Also, please make sure to allow this type of license to embed the program into the program. [Path] In the file specified by Zero ExtractResource (string processing)
// extract [resource], string path) {stream stream = GetType (). Assembly.GetManifestResourceStream (resource); Byte [] bytes = new byte [(int) stream. Length]; Stream Read (bytes, 0, bytes lang); File. WritAllBytes (path, bytes); } String exePath = "c: \ temp \ embedded.exe"; ExtractResource ("myProj.embedded.exe", exePath); Run // exe ... file Remove (exePath); The only hard part is getting the correct value for the first argument of ExtractResource in that the form should be "namespace.name", where namespace is the default for your project Namespace (find it under project | properties | app | default namespace). The second part is the name of the file, which you must include in your project (be sure to set the build option on "Embedded Resources"). If you put the file under a directory, eg Resource, then that name becomes part of the resource name (like "myProj.Resources.Embedded.exe"). If you are having trouble, try opening your compiled binary in the reflector and viewing it in the Resources folder. The names listed here are the names that you get from GetManifestResourceStream .
Comments
Post a Comment