473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Difference in getting the current exe directory

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
Jun 27 '08 #1
2 2599
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:
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
Jun 27 '08 #2
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" <ro**********@gmail.comwrote in message
news:1f**********************************@c19g2000 prf.googlegroups.com...
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

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NathanK | last post by:
Hi Guys, im starting out in java and i'm getting the error: Exception in thread "main" java.lang.NoClassDefFoundError: blurf if i run "javac blurf.java", it compiles fine and without any...
3
by: Kali K E | last post by:
Hi, I could not understand how I can do the following things in Python. Please help me. 1. First I have to find the current directory from where the script is invoked. 2. Next I have to form a...
12
by: MikeT | last post by:
I have a page that produces little thumbnails of the 3D models it finds in a specified directory (and iterates down through any sub directories). It basically scans each directory for 3D Studio...
2
by: David Hearn | last post by:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred during the execution of the current...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
3
by: artifact.one | last post by:
Hi. What's the practical difference between: #include <header.h> and: #include "header.h"
1
by: mikebian | last post by:
I created a db that houses info about pictures that were scanned into the PC. The pictures are stored on the file system. I have a form coded so that it shows thumbnails of the images, which are...
5
by: daveh551 | last post by:
What, from a high level point of view, is the difference (in Visual Studio 2005) between Website (accessed with Open Website or Create Website from the StartPage) that is an ASP.NET Website, and a...
15
denny1824
by: denny1824 | last post by:
I have a working website. I copied all the files to a new folder in inetpub/wwwroot and then set that folder as a Virtual Directory in IIS. I try going to that site from the new folder and i am...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.