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

Q: Getting a directory

Hiya

I have written a small application which I've then generated a setup project
to install the application on other computers.

How can I determine, from the application, where the program has been
installed to?

Thanks in advance

Geoff
Nov 21 '05 #1
11 1125
Application.StartupPath()

Chris

"Geoff Jones" <no********@email.com> wrote in message
news:42**********************@news.dial.pipex.com. ..
Hiya

I have written a small application which I've then generated a setup
project to install the application on other computers.

How can I determine, from the application, where the program has been
installed to?

Thanks in advance

Geoff

Nov 21 '05 #2
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
How can I determine, from the application, where the program has been
installed to?


'Application.StartupPath' (for Windows Forms applications). For libraries,
console applications, etc. (ignore the text and take a look at the code):

<URL:http://dotnet.mvps.org/dotnet/code/application/#ApplicationPath>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Hi Herfried

Thanks for the suggestion. It isn't exactly what I want; although I didn't
make myself very clear.

Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the path
to this folder.

I guess this is done using the registry etc. but I'm unsure how to proceed.

Can you be of any further help?

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
How can I determine, from the application, where the program has been
installed to?


'Application.StartupPath' (for Windows Forms applications). For
libraries, console applications, etc. (ignore the text and take a look at
the code):

<URL:http://dotnet.mvps.org/dotnet/code/application/#ApplicationPath>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the path
to this folder.


Typically, the executable is installed into this directory.

You can use a WMI query ('System.Management') with the 'Win32_Product' class
and check its 'InstallLocation' property:

Platform SDK: Windows Management Instrumentation -- 'Win32_Product'
<URL:http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_product.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Geoff,
I would use 'Application.StartupPath' as that is the path where the
executable is, it normally will be the path where it is installed to, unless
the user manually copies or moves the exe.

I would use System.IO.Path to get the individual parts of the StartupPath...

In addition to a WMI query to find the folder where it was installed, you
could have the Setup Project create a registry key that contains the path
where the app was installed to.

Hope this helps
Jay
"Geoff Jones" <no********@email.com> wrote in message
news:42*********************@news.dial.pipex.com.. .
Hi Herfried

Thanks for the suggestion. It isn't exactly what I want; although I didn't
make myself very clear.

Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the path
to this folder.

I guess this is done using the registry etc. but I'm unsure how to
proceed.

Can you be of any further help?

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
How can I determine, from the application, where the program has been
installed to?


'Application.StartupPath' (for Windows Forms applications). For
libraries, console applications, etc. (ignore the text and take a look at
the code):

<URL:http://dotnet.mvps.org/dotnet/code/application/#ApplicationPath>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #6
Hi Jay

I'm interested further in your last point. I had a look at the deployment
project and couldn't see any options to writing to the registry. Just to
clarify, I am using the inbuilt deployment project in Visual Studio.

Could you help further?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u2***************@TK2MSFTNGP15.phx.gbl...
Geoff,
I would use 'Application.StartupPath' as that is the path where the
executable is, it normally will be the path where it is installed to,
unless the user manually copies or moves the exe.

I would use System.IO.Path to get the individual parts of the
StartupPath...

In addition to a WMI query to find the folder where it was installed, you
could have the Setup Project create a registry key that contains the path
where the app was installed to.

Hope this helps
Jay
"Geoff Jones" <no********@email.com> wrote in message
news:42*********************@news.dial.pipex.com.. .
Hi Herfried

Thanks for the suggestion. It isn't exactly what I want; although I
didn't make myself very clear.

Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the
path to this folder.

I guess this is done using the registry etc. but I'm unsure how to
proceed.

Can you be of any further help?

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
How can I determine, from the application, where the program has been
installed to?

'Application.StartupPath' (for Windows Forms applications). For
libraries, console applications, etc. (ignore the text and take a look
at the code):

<URL:http://dotnet.mvps.org/dotnet/code/application/#ApplicationPath>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Nov 21 '05 #7
Thanks Herfried

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oj**************@TK2MSFTNGP14.phx.gbl...
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the
path to this folder.


Typically, the executable is installed into this directory.

You can use a WMI query ('System.Management') with the 'Win32_Product'
class and check its 'InstallLocation' property:

Platform SDK: Windows Management Instrumentation -- 'Win32_Product'
<URL:http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_product.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
Geoff,

All about the stephchild Deployment and Setup project seems to be hidden you
would expect it under Edit however it is.

When you have opened a setup project

View -> Editor ->Registry

I hope this helps?

Cor
Nov 21 '05 #9
Thanks Cor. That makes a lot more sense now.

K

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
Geoff,

All about the stephchild Deployment and Setup project seems to be hidden
you would expect it under Edit however it is.

When you have opened a setup project

View -> Editor ->Registry

I hope this helps?

Cor

Nov 21 '05 #10
Geoff,
Rather then use the View menu that Cor suggests I simply use the tool bar in
the Solution Exporer when the Setup Project itself is selected.

The trick is finding the variable names that you may want to write. I
normally refer to the Windows Installer Property reference:

http://msdn.microsoft.com/library/de..._reference.asp

Hope this helps
Jay

"Geoff Jones" <no********@email.com> wrote in message
news:42*********************@news.dial.pipex.com.. .
Hi Jay

I'm interested further in your last point. I had a look at the deployment
project and couldn't see any options to writing to the registry. Just to
clarify, I am using the inbuilt deployment project in Visual Studio.

Could you help further?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u2***************@TK2MSFTNGP15.phx.gbl...
Geoff,
I would use 'Application.StartupPath' as that is the path where the
executable is, it normally will be the path where it is installed to,
unless the user manually copies or moves the exe.

I would use System.IO.Path to get the individual parts of the
StartupPath...

In addition to a WMI query to find the folder where it was installed, you
could have the Setup Project create a registry key that contains the path
where the app was installed to.

Hope this helps
Jay
"Geoff Jones" <no********@email.com> wrote in message
news:42*********************@news.dial.pipex.com.. .
Hi Herfried

Thanks for the suggestion. It isn't exactly what I want; although I
didn't make myself very clear.

Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the
path to this folder.

I guess this is done using the registry etc. but I'm unsure how to
proceed.

Can you be of any further help?

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
Geoff,

"Geoff Jones" <no********@email.com> schrieb:
> How can I determine, from the application, where the program has been
> installed to?

'Application.StartupPath' (for Windows Forms applications). For
libraries, console applications, etc. (ignore the text and take a look
at the code):

<URL:http://dotnet.mvps.org/dotnet/code/application/#ApplicationPath>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Nov 21 '05 #11
Hi Jay

Thanks. Very useful link.

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ej*************@TK2MSFTNGP15.phx.gbl...
Geoff,
Rather then use the View menu that Cor suggests I simply use the tool bar
in the Solution Exporer when the Setup Project itself is selected.

The trick is finding the variable names that you may want to write. I
normally refer to the Windows Installer Property reference:

http://msdn.microsoft.com/library/de..._reference.asp

Hope this helps
Jay

"Geoff Jones" <no********@email.com> wrote in message
news:42*********************@news.dial.pipex.com.. .
Hi Jay

I'm interested further in your last point. I had a look at the deployment
project and couldn't see any options to writing to the registry. Just to
clarify, I am using the inbuilt deployment project in Visual Studio.

Could you help further?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u2***************@TK2MSFTNGP15.phx.gbl...
Geoff,
I would use 'Application.StartupPath' as that is the path where the
executable is, it normally will be the path where it is installed to,
unless the user manually copies or moves the exe.

I would use System.IO.Path to get the individual parts of the
StartupPath...

In addition to a WMI query to find the folder where it was installed,
you could have the Setup Project create a registry key that contains the
path where the app was installed to.

Hope this helps
Jay
"Geoff Jones" <no********@email.com> wrote in message
news:42*********************@news.dial.pipex.com.. .
Hi Herfried

Thanks for the suggestion. It isn't exactly what I want; although I
didn't make myself very clear.

Using the Deployment project, the application is stored in a directory
called, for example, ABC Ltd, which is the "Manufacturer" producing the
software. What I'd like to do is to find, within the application, the
path to this folder.

I guess this is done using the registry etc. but I'm unsure how to
proceed.

Can you be of any further help?

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uM**************@TK2MSFTNGP15.phx.gbl...
> Geoff,
>
> "Geoff Jones" <no********@email.com> schrieb:
>> How can I determine, from the application, where the program has been
>> installed to?
>
> 'Application.StartupPath' (for Windows Forms applications). For
> libraries, console applications, etc. (ignore the text and take a look
> at the code):
>
> <URL:http://dotnet.mvps.org/dotnet/code/application/#ApplicationPath>
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Nov 21 '05 #12

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

Similar topics

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...
8
by: Opa | last post by:
Hi, Does anyone know how to get a list of files for a given directory from a given url. I have the following, but get an error indicating that URI formats are not supported. ...
6
by: Binoy | last post by:
Hello, I am getting this error once in a while from my web sites. When I will refresh web browser, it goes off and sites are working fine. Directory structures and file names are as below- ...
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) :...
8
by: lawrence k | last post by:
I've installed Apache 1.3.36 on my Redhat EL 3 machine. Now I'm trying to install PHP 5.1.4. I can not get the ./configure command to work. I keep getting this error: configure: error: Invalid...
4
by: herc | last post by:
My objective is to get the "label" information for the different volumes that are mounted. I want to display the same information as Windows Explorer. I wrote this test code with gets me the...
5
by: Michael Howes | last post by:
I'm writing a utility to manage a machines *local* accounts in c# I am getting all the users in a specific Group just fine but when I want to get some of the information on each user from their...
13
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are...
3
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am getting the following error :- 1>------ Build started: Project: Polygon Drawer, Configuration: Debug Win32 ------ 1>Compiling... 1>Dialog.cpp 1>g:\my subjects\3rd semester\project...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.