Click here to Skip to main content
16,002,004 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I install the package through setup.MSI & assign the location of my Package setup i.e.('C:\Program Files\Tech Soft\MNCP Setup\').
My point of view that, How will I get assigning location of my Package setup through debugging mode i.e.(I want to get Package location 'C:\Program Files\Tech Soft\MNCP Setup')????
Please help me.....
Posted
Comments
Sergey Alexandrovich Kryukov 2-Dec-11 19:52pm    
Why do you need that?
--SA

1 solution

I don't think you ever need it. The first feature of your application should be able to run in and directory. You should test that this holds in all cases during development/testing, before you get to installation. When you do development, you should have at least two different output directories (usually, on for Release, another for Debug configuration), and your code should work equally well in any of them, as well as in any other directory on this or another computer. When you deploy it using setup, it should also work.

Now, do you need to determine the location of your assembly and application during run-time? Here is the most reliable method:

If you have some assembly, use System.Reflection.Assembly.Location. If your code is running in an application, you should be able to determine the location of the main module of the application's entry assembly (where the entry point like Main was called). The following code works this way:

C#
string exeLocation = 
   System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);


There are other methods, but some of them gives different results depending on how the application is hosted: debug host or hosting by Service Controller can give different results. So, please use the method I've shown.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900