Can I add external .exe to my C# project so that i don't need any path to access it as outside app? I want to embed it as my project resource? Thanks in advance
Asked
Active
Viewed 7,742 times
4
-
I don't think you can, at least I've never done it that way. I would use a config file to store the path of the external exe so it can be easily changed. – Bugs Jul 13 '18 at 13:58
-
you could, but in order to run it, you'd still have to extract it and `Process.Start` it, or use one of the concepts [presented here](https://stackoverflow.com/a/3553911/1132334), a bit easier for managed code, a bit heavy lifting for PE code. If it has dependencies, it will be a whole different story and won't work without an installer. – Cee McSharpface Jul 13 '18 at 13:59
-
if you store it in the resources you can always extract it in the Windows Temp folder and run it from there. – Nyerguds Jul 13 '18 at 16:34
1 Answers
9
You can add file by right-clicking on the project, or drag-n-drop works.
You can add your exe in your solution and set its Build Action: Content
and Copy to output Directory: Copy always
.
The installer should automatically include the file.
Hope this helps

Fuzzybear
- 1,388
- 2
- 25
- 42
-
Could you explain the steps. I am not very experienced in C#. Thanks in advance. – Abhi Jul 13 '18 at 16:51
-
It is more Visual Studio than c# here.... drag and drop the exe you have from a windows explorer into your Solution manager to add the exe to the project. – Fuzzybear Jul 13 '18 at 16:56
-
then click on the exe that has just been added in the solution explorer window and open up the Properties tab, in here you have two options 1) Build action and 2) Copy to Output Directory. These are the fields you want to set as in my answer and that should do it – Fuzzybear Jul 13 '18 at 16:58