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.

Re: Application Physical Path by Jani

Jani
Fri Jan 25 08:40:36 CST 2008

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
janij@removethis.dystopia.fi
http://www.saunalahti.fi/janij/



Re: Application Physical Path by newscorrespondent

newscorrespondent
Thu Jan 31 19:28:36 CST 2008

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.

Re: Application Physical Path by Ravi

Ravi
Tue Feb 05 12:56:44 CST 2008

Application.ExecutablePath

Hope this helps,

/ravi

----------
"mohaaron" <mohaaron@gmail.com> wrote in message
news:4e88cea0-85b9-480f-bdb2-f8bf41a59abe@f10g2000hsf.googlegroups.com...
> 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.