Hi
I need to get a installation path of a already installed application in windows Xp,window 7.How can I retrive the installed folder path in C#.My program does not have any directory information in Registry.
Please Help
Thanks In Advance
Devopriyo Seal
Loading

Sam HobbsRank #107 · 20.5K reputationPosted Feb 24, 2012, 1:26 PM EST
Are you saying that you need to determine where the application you wrote was installed? What was used to install it?
Try this. Can you find your application (or the application) in "Control Panel | Programs and Fetures"? If you can then there are a couple of ways to get the information; one way was faster for me compared to the other but I forget which is faster. WMI is one way and you can use the .Net Management classes to use that. Does that sound like what you need?
VulpesRank #55 · 29.2K reputationPosted Feb 24, 2012, 12:19 AM EST
System.Reflection.Assembly.GetExecutingAssembly().Location
devopriyo Seal3 reputationPosted Feb 24, 2012, 6:15 PM EST
For your suggestion I have done following and its working.
ManagementObjectSearcher MyWMIQuery = new ManagementObjectSearcher("SELECT * FROM Win32_Product where Caption='"+"MyAPps 3.1"+"'");
ManagementObjectCollection MyWMIQueryCollection = MyWMIQuery.Get();
foreach(ManagementObject MyMO in MyWMIQueryCollection)
{
string Path = (MyMO["InstallLocation"] == null ? " " : MyMO["InstallLocation"].ToString());
}
MyWMIQueryCollection = null;
MyWMIQuery = null;
Sam HobbsRank #107 · 20.5K reputationPosted Feb 24, 2012, 7:31 PM EST