Application Physical Path

  • Thread starter Thread starter mohaaron
  • Start date Start date
M

mohaaron

Can anyone tell me how to get the physical path where an application
lives? What I mean by an application is either a Windows Service or a
Winforms application. I know in asp.net Server.MapPath is what's used.
I need some type of equivelent for a non asp.net application.

The reason I need this is that I'm trying to write a file to a folder
on a server that I don't have access to. The only access I have is a
mapped drive to the machine where my Windows Service is going to be
installed. What I would like to do is get the physical path to a
directory which is actually a sub-directory of a web site on this
machine. If that is too diffecult to do then the physical path which
the Windows Service dll resides would also work as a secondary option.

Thanks.
 
Hello,

I'm not exactly sure if I got your question right, but if you want to know
the name of the executing process on a WinForms application, you could use
the System.Environment.CommandLine property. This is often the easiest way,
and should work on Windows Service applications, too.

Then, you had a question accessing server paths. If you have a mapped
network drive, then you could just copy your application there. But if you
are indeed talking of Windows service applications (.exe based), then simply
copying won't work, as the service has to be registered on the server
computer. For this to succeed, you will need proper rights to the server.

Hope this helps.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
(e-mail address removed)
http://www.saunalahti.fi/janij/
 
The path to an application depends on how it was installed. An installer
program puts it one place and a click-once install puts it another that
would not be very useful for what you want to do.
 
Back
Top