Joshua Magee
Joshua Magee

Reputation: 11

Embedding .exe's into a VB.net application

So here's whats up, I am a Bench Technician for an IT company. I find myself repeating the same task over and over when preforming system reloads. I want to write an application where I have all the programs for a reload in one spot, and call them by a button click event. I have tried adding them into the Resources and calling them by Environment.CurrentDirectory+"\Path" to no avail, I get " System cannot find the file specified. When the path is hard coded it works like a charm, but this will obviously not do as it needs to be able to move to any system. I am looking for a way to add the exe's I need and a generic way to call the path. I am not looking for handouts here, I have done my homework on this one and still not found a solution, If I could get someone to -point me in the right direction, it would be awesome.

Upvotes: 0

Views: 110

Answers (1)

Behrooz
Behrooz

Reputation: 1734

Since what you have already tried is much saner and easier for the average user to work with than having the files embedded in another executable, I'll explain that method.
CurrentDirectory is where your executable is executed from, Like this:

C:\MyDir> MyOtherDir\MyProgram.exe

CurrentDirectory refers to C:\MyDir in this example.

What you need is the application directory; and according to top answer of this question the most reliable way to get that is using AppDomain.CurrentDomain.BaseDirectory

EDIT: Also consider using Path.DirectorySeparatorChar instead of \.

Upvotes: 1

Related Questions