1

I'm working with Visual Studio 2010, .NET4 C# and my solution has a setup project.

As you probably know, the installation path of the program can be found in the properties of the application folder inside the File System Editor (DefaultLocation property).

How can I access this string inside the code?

My goal: I've got an installer class which defines actions to be done after installation. I want to take the path and add it to the registry as a startup program.

CodeMonkey
  • 11,196
  • 30
  • 112
  • 203

1 Answers1

0

If you want the install folder, then this code should work:

//getting the full path including the filename
string assemblyPath = Context.Parameters["assemblyPath"];
//removing the filename from the path
int i = assemblyPath.Length-1;
while (assemblyPath[i] != '\\') --i;
string path = assemblyPath.Substring(0, i);

if you want the full path including the filename it is stored here:

Context.Parameters["assemblyPath"]
KronuZ
  • 378
  • 2
  • 13