Application.StartupPath equivalent for a console app?

C

Cleetus Awreetus

It doesn't look like the Application namespace is available in a console
app. I want to be able to use Application.StartupPath to get the path
that the program was started in. Is there a console app equivalent for
this?

Steve
 
T

Teemu

Cleetus Awreetus said:
It doesn't look like the Application namespace is available in a console
app. I want to be able to use Application.StartupPath to get the path
that the program was started in. Is there a console app equivalent for
this?

Steve

Here is one solution:

Console.WriteLine(My.Application.Info.DirectoryPath)

-Teemu
 
F

Family Tree Mike

Cleetus Awreetus said:
It doesn't look like the Application namespace is available in a console
app. I want to be able to use Application.StartupPath to get the path
that the program was started in. Is there a console app equivalent for
this?

Steve


If you add a reference to System.Windows.Forms, then add an Imports
statement, it will still work in a console app.
 
H

Herfried K. Wagner [MVP]

Cleetus Awreetus said:
It doesn't look like the Application namespace is available in a console
app. I want to be able to use Application.StartupPath to get the path
that the program was started in. Is there a console app equivalent for
this?

\\\
Public Module Helpers
Public ReadOnly Property ApplicationPath() As String
Get
Return _
Path.GetDirectoryName([Assembly].GetEntryAssembly().Location)
End Get
End Property
End Module
///

Usage: 'Dim AppPath As String = Helpers.ApplicationPath'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top