Service. exe path.

  • Thread starter Thread starter Odd A Haugum
  • Start date Start date
O

Odd A Haugum

Hi

I'm creating a .NET service.
I want to read settings from a txt file placed in the same folder as the exe
file.
The file has the same name as the exe file.

In VB6 I used app.path to find the path.
In .Net I can use 'application.startupPath'.

But when I create a service, I cant use the application object.

Does anyone know how I can retrieve the path and the exe name in a service
project?

Regards
Odd Anders.
 
* "Odd A Haugum said:
I'm creating a .NET service.
I want to read settings from a txt file placed in the same folder as the exe
file.
The file has the same name as the exe file.

In VB6 I used app.path to find the path.
In .Net I can use 'application.startupPath'.

But when I create a service, I cant use the application object.

Untested:

\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Back
Top