Dean
Dean

Reputation: 5946

How to pass in the directory that you have been run from to an executable in VB

This may be simple but I have brain freeze on just now

If I cd into a directory from a command line and then run my executable VB.net application, is there a way to detect the directory that it was launched from.

I currently have the executable in my PATH however ideally the person would cd into the directory that they were wanting the executable to act upon.

Is this possible?

Upvotes: 0

Views: 96

Answers (3)

iburlakov
iburlakov

Reputation: 4232

You can use this Environment.CurrentDirectory.

Upvotes: 1

Fredrik Mörk
Fredrik Mörk

Reputation: 158309

Environment.CurrentDirectory gives you that information. Note that this property is also assignable, so you can change the current working directory by assigning a new value to it.

Upvotes: 0

Adam Ruth
Adam Ruth

Reputation: 3655

IO.Directory.GetWorkingDirectory() will get you the directory you CD'd to.

Upvotes: 1

Related Questions