How to add External .exe to my C# project?
Asked Answered
H

1

5

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

Hampstead answered 13/7, 2018 at 13:54 Comment(3)
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.Disfeature
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, 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.Painter
if you store it in the resources you can always extract it in the Windows Temp folder and run it from there.Renferd
B
11

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

Boxer answered 13/7, 2018 at 13:59 Comment(3)
Could you explain the steps. I am not very experienced in C#. Thanks in advance.Hampstead
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.Boxer
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 itBoxer

© 2022 - 2024 — McMap. All rights reserved.