Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add and path to call third party binary in solution

Status
Not open for further replies.

perlnewbie9292

Programmer
Jul 15, 2009
25
0
0
US
Hello,

I am pretty new to C#. I am trying to figure out a few things.

I dragged a binary (which is console application) to my project. This cosole APP will be required to be installed/be part of the project when I do a build. Is this the right to do this, I want it to be copied when the user runs through the install.

My other question is how to I call/access this binary in my project after I drag it into project explorer? At the moment while testing I was pointing to via its path. Sample code below

For example:
Code:
#decode.exe is the cosole app I want added to the project
#what will the path be once it's imported to the project?
string parserConsoleApp = @"C:\decode.exe";

Process newProcess = new Process();
newProcess.StartInfo.FileName = parserConsoleApp;

So with the code above I imported this into my project and want it to be deployed as part of the build, how would I call/access this binary when declaring the string: parserConsoleApp? What is the path change to once it's imported into the project.

Thanks for the help in advanced.
 
a Console app is a UI, same as a winform or web interface. it's also the most basic. typically calling from one UI into another is not a good practice. it's the part of the system that is most likely to change and hardest to change.

instead you would create an assembly with a public API. the public API are the objects and method the client code would call to execute some operation.

To access the API from another project you would add a reference to the assembly containing the API to the UI project. All this is done through the VS IDE. you can then declare objects and call methods.

you don't need VS, you could just use note pad and the csharp compiler. I'm not sure how to do that though. VS is the one IDE I'm dependent on.

If designing an API is out of the question, then you continue with your current approach. You won't need to reference the console app as there isn't a direct relation between the two. Making the console app part of the deployment process is independent of referencing the object in the code.

I believe you can use a relative path "decode.exe" and the Process will search the directory your UI application is in.
[tt]
/root
/myapp.exe
/decode.exe
/other assemblies as needed.
[/tt]
you can get the root path using
Code:
var basePath = AppDomain.CurrentDomain.BaseDirectory;
var decoderPath = Path.Combine(basePath, "decoder.exe");

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
that worked, your a genius.

Thank you very much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top