Application.StartupPath equivalent for a console app?

  • Thread starter Thread starter Cleetus Awreetus
  • Start date Start date
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
 
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
 
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.
 
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'.
 
Back
Top