473,382 Members | 1,745 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,382 software developers and data experts.

Path of the running application

Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan
Nov 16 '05 #1
7 7969
Nhan,

You can get the entry point for the application by calling the static
GetEntryPoint method on the Assembly type and getting the entry point of the
assembly that was used to launch the CLR.

Once you have that, you can use the Location property on the assembly
returned to find out where it is being executed from.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Le, Thanh-Nhan" <le*****@freenet.de> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan

Nov 16 '05 #2
Use Application.StartupPath.

"Le, Thanh-Nhan" <le*****@freenet.de> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan

Nov 16 '05 #3
You can use the System.Windows.Forms.Application object's ExecutablePath
property.

See
http://msdn.microsoft.com/library/de...epathtopic.asp

Cheers,

Shariq Khan
sh****@shariqkhan.com
"Le, Thanh-Nhan" <le*****@freenet.de> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan

Nov 16 '05 #4
> How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).


I assume that you want the path where the executable is located that is now
running?

Something like this:

using System.Reflection;

Assembly myAssembly = Assembly.GetExecutingAssembly();
string ExecutableFileAndPath=myAssembly.CodeBase;
string ThePath=Path.GetFullPath(ExecutableFileAndPath);
--
http://www.skyscan.be
Nov 16 '05 #5
Thanks

"Shariq Khan" <sh****@shariqkhan.com> schrieb im Newsbeitrag
news:eK**************@TK2MSFTNGP14.phx.gbl...
You can use the System.Windows.Forms.Application object's ExecutablePath
property.

See
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsapplicationclassexecutablep athtopic.asp
Cheers,

Shariq Khan
sh****@shariqkhan.com
"Le, Thanh-Nhan" <le*****@freenet.de> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan


Nov 16 '05 #6
Thanks

"Olaf Baeyens" <ol**********@skyscan.be> schrieb im Newsbeitrag
news:41**********************@news.skynet.be...
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).
I assume that you want the path where the executable is located that is

now running?

Something like this:

using System.Reflection;

Assembly myAssembly = Assembly.GetExecutingAssembly();
string ExecutableFileAndPath=myAssembly.CodeBase;
string ThePath=Path.GetFullPath(ExecutableFileAndPath);
--
http://www.skyscan.be

Nov 16 '05 #7
thanks

"Shiva" <sh******@online.excite.com> schrieb im Newsbeitrag
news:OD**************@TK2MSFTNGP09.phx.gbl...
Use Application.StartupPath.

"Le, Thanh-Nhan" <le*****@freenet.de> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan

Nov 16 '05 #8

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

Similar topics

1
by: Pierre Rouleau | last post by:
I can't remember where/how sys.path is set (aside from the automatically loaded site.py) and i get a strange entry in it. Can anyone remind me where/how to control sys.path on a Win32 machine (i'm...
9
by: Bengt dePaulis | last post by:
I have a local directory that I want to include in my sys.path How to save it permanently? Regards /Bengt
1
by: Chris B | last post by:
I have an application that uses PInvoke to call into native DLLs. My DLLimport attribute only has the name of the DLL that I need to import (i.e. I leave it up to the OS to search the PATH for the...
3
by: Jon | last post by:
I'm calling Server.MapPath from global.asa through this line of code: Application("reports_dir") = Server.MapPath("Reports") The web application opens on a testing web server (not mine) at this...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
3
by: bobdydd | last post by:
Hi Everybody Access 2000, Outlook 2000 Windows XP I am running the code below to open Microsoft Outlook from a Command Button. It works fine until I tried it on a machine that has Office...
0
by: emu | last post by:
Hi All, I have an unmanaged C++ application that references a mixed mode image DLL (mixed managed and unmanaged). Under .NET 1.1 we could trust the dll (the mixed mode dll) by running the...
8
by: Mark Rae | last post by:
Hi, I'm developing an intranet for a client. On my development machine, I have created a virtual directory called, fairly unimaginatively, intranet. However, the client wants to deploy the app...
4
by: =?Utf-8?B?WWFlbA==?= | last post by:
Hi, I want to check if in this computer have outlook a programe. If yes --> System.Diagnostics.Process.Start ("OUTLOOK.EXE"); How to check if no?? if no --some msg... How can I check it? How...
1
by: crusson | last post by:
(edited to add): this is in Visual Basic .net I am at a complete loss... I've been building a program on my machine, running it out of the developer with the f5 key and builidng it and running...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.