I have a binary that’s used as a command-line tool to manipulate some files – tool.exe. I would like to include this in my Visual Studio 2008 project and use it from my C# code. I have it in a folder called “Resources” which also has some other files my project uses.
I would like to do something like Process myproc = Process.Start("Resources/tool.exe"); but I believe C# has an issue with this because it’s looking in the file system rather than the project.
How can this be done?
You are pretty much describing the correct way to do this. You have to make sure that the binary file is set to be copied to the correct location relative to your application – you do this by setting the
Build actiontocontent(in the file properties), so it will get copied to the correct location.This build action defaults the
Copy to Ouput directoryproperty toCopy Always, which in this case is safe to beCopy if newer. Make sure it is one of these two.See this SO question and answers for more details.