473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I find the installation dorectory from code

I want my app to create a file in a convenient exisiting folder. The logical
place to craete it would be the application's installation folder. Is there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help states
"The program name can, but is not required to, include path information."
--
Dave
Jan 4 '06 #1
5 2723

Dave wrote:
I want my app to create a file in a convenient exisiting folder. The logical
place to craete it would be the application's installation folder. Is there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help states
"The program name can, but is not required to, include path information."


Application.StartupPath will do what you want.

Matt

Jan 4 '06 #2
How about Assembly.GetEntryAssembly().CodeBase or one of the other
properties.

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
I want my app to create a file in a convenient exisiting folder. The
logical
place to craete it would be the application's installation folder. Is
there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help
states
"The program name can, but is not required to, include path information."
--
Dave

Jan 4 '06 #3
Found it - Application.ExecutablePath.
Shouldn't be so eager to post
--
Dave
"Dave" wrote:
I want my app to create a file in a convenient exisiting folder. The logical
place to craete it would be the application's installation folder. Is there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help states
"The program name can, but is not required to, include path information."
--
Dave

Jan 4 '06 #4

Dave wrote:
Found it - Application.ExecutablePath.
Shouldn't be so eager to post


StartupPath is easier, you don't have to remove the executable name
that way.

:)

Matt

Jan 4 '06 #5
Not to leave out System.Environment.CurrentDirectory. They all have slightly
different effects and applications.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dave" wrote:
I want my app to create a file in a convenient exisiting folder. The logical
place to craete it would be the application's installation folder. Is there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help states
"The program name can, but is not required to, include path information."
--
Dave

Jan 5 '06 #6

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

Similar topics

7
11798
by: Paul Rubin | last post by:
I'm writing a Windows program that needs to store some user files. The logical place to store them is in "Application Data", right? Is there a good way to find the correct location of that...
1
3173
by: Hai-Chu Hsu | last post by:
Hi, I want to restore my databases from the old SQL Server installation into a new installation of SQL Server. My new installation of SQL Server has different data path from the old...
4
7394
by: Bill Murray | last post by:
I am using VS.NET 2003 and trying to deploy a service program(c++) to a Windows 2000 Server system. I have also written a small DLL (USSsetup.dll) that is used to start/stop the service using a...
0
1820
by: InstallAware | last post by:
For Press Inquiries: Sinan Karaca InstallAware Software Corporation 336 Guerrero Street, San Francisco CA 94103 415 358 4094 (voice/fax) sinank@installaware.com http://www.installaware.com/ ...
1
8076
by: srihari | last post by:
Hai, I am trying to install IBM DB2 8.1 on Red Hat linux 8.0. My machine is Intel XEON 64bit. The installation went well except for the creation of tools catalog. When I tried to install the tools...
4
7286
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always...
1
9950
by: jobs | last post by:
Seems like I followed all steps but I can't find my service in the service manager?? f:\windowsservice\EmptyService\EmptyService\bin\Debug>InstallUtil EmptyS ervice.exe Microsoft (R) .NET...
6
1266
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2, C# for windows application. In my application, I use a C coded file that I use VS to compile into a dll for some of it's functions. It works on my devvelopment PC. ...
0
2739
by: zaza24 | last post by:
Hello there I am loosing my time since a few days trying to install a CRM (ACT! 2008 version 10) software on a brand new HP notebook with Vista prof OS. Ths installation do not show any...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.