Detect local application path
How do I detect my local application path?
When launched from a Web server .NET applications are
copied in the assembly download cache (ADC) of the
client machine.
Note: Please be aware that you have no right
to read or write within that location by default and
need to assign the necessary permissions or FullTrust
to the assembly.
When you write a Windows Forms application there are
basically four ways how to determine your application
path.
-
Application.ExecutablePath (Windows.Forms)
- Assembly.CodeBase
(Reflection)
-
AppDomain.CurrentDomain.BaseDirectory
(System)
These three return the URL to the folder on the web
server the application was launched from. And finally...
- Assembly.Location
(Reflection)
... returns the local path in the assembly download
cache (assuming the necessary permissions).
[Comments]
|