Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Difference in getting the current exe directory

Reply
 
Old 06-24-2008   #1 (permalink)
Kakkanattu


 
 

Difference in getting the current exe directory

AppDomain.BaseDirectory
Gets the base directory that the assembly resolver uses to probe for
assemblies and it is similar to AppDomainSetup.ApplicationBase.

Environment.CurrentDirectory
Gets or sets the fully qualified path of the current working directory.

Directory.GetCurrentDirectory()
Gets the current working directory of the application. Obviusly it is an
read only method.

Assembly.GetExecutingAssembly().Location
Gets the path or UNC location of the loaded file that contains the manifest.

"Kakkanattu" <robinmathewk@xxxxxx> wrote in message
news:1f48008e-db9d-40ef-a7cb-4acf6f375ee9@xxxxxx
Quote:

> Hi,
> In desktop application, we use different ways to get the current
> execution directory.
> I. AppDomain.CurrentDomain.BaseDirectory
> II. Environment.CurrentDirectory
> III. Directory.GetCurrentDirectory()
> IV. Assembly.GetExecutingAssembly().Location
>
> Can u please help me to know the difference of all these? Also is
> there any other way to get the current directory other than the above?
>
> Thanks in advance
> Robin Mathew

My System SpecsSystem Spec
Old 06-24-2008   #2 (permalink)
Family Tree Mike


 
 

RE: Difference in getting the current exe directory

More often than not, only 2 and 3, which are equivalent, will get the current
directory.

1 "Gets the base directory that the assembly resolver uses to probe for
assemblies.", per MSDN.

4 gets the location of the assembly that is executing. When a shortcut to
an executable is used, the current directory may be different than the
executable location.

I suspect there are many other ways to get the current location.

"Kakkanattu" wrote:
Quote:

> Hi,
> In desktop application, we use different ways to get the current
> execution directory.
> I. AppDomain.CurrentDomain.BaseDirectory
> II. Environment.CurrentDirectory
> III. Directory.GetCurrentDirectory()
> IV. Assembly.GetExecutingAssembly().Location
>
> Can u please help me to know the difference of all these? Also is
> there any other way to get the current directory other than the above?
>
> Thanks in advance
> Robin Mathew
>
My System SpecsSystem Spec
Old 06-25-2008   #3 (permalink)
Mathew Coleman


 
 

Re: Difference in getting the current exe directory

AppDomain.BaseDirectory
Gets the base directory that the assembly resolver uses to probe for
assemblies and it is similar to AppDomainSetup.ApplicationBase.

Environment.CurrentDirectory
Gets or sets the fully qualified path of the current working directory.

Directory.GetCurrentDirectory()
Gets the current working directory of the application. Obviusly it is an
read only method.

Assembly.GetExecutingAssembly().Location
Gets the path or UNC location of the loaded file that contains the manifest.

"Kakkanattu" <robinmathewk@xxxxxx> wrote in message
news:1f48008e-db9d-40ef-a7cb-4acf6f375ee9@xxxxxx
Quote:

> Hi,
> In desktop application, we use different ways to get the current
> execution directory.
> I. AppDomain.CurrentDomain.BaseDirectory
> II. Environment.CurrentDirectory
> III. Directory.GetCurrentDirectory()
> IV. Assembly.GetExecutingAssembly().Location
>
> Can u please help me to know the difference of all these? Also is
> there any other way to get the current directory other than the above?
>
> Thanks in advance
> Robin Mathew

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How can I Write-Host the current directory? PowerShell
bug in join-path when the current directory is used PowerShell
how do I keep powershells current directory and dotnets current directory in sync PowerShell
Executing scripts in the current directory PowerShell
Manipulating current directory as a variable PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46