title: Visual Studio Install Project: Get Target Directory
body: <p>I've been digging around Google trying to find the appropriate way to determine the installation path selected by a user from the install wizard.</p>
  
  <p>Basically I'm running into an issue where my service can't create files in it's own directory because it lacks the proper permissions. I'm assuming the correct way to resolve this is to make sure that whatever account the service is using is given appropriate file permissions on it's folder.</p>
  
  <p>But before I can even tackle how to set permissions through .Net I need to know the installation folder. I'm using an install project which has an Installer class which contains a <code>ServiceInstaller</code> control as well. Both have the <code>Context</code> property so I've been checking that for the parameters that are available when the AfterInstall event fires for each of the respective installers. I thought at first I'd be seeing the <code>TargetDir</code> property set but that hasn't been the case. I am however seeing <code>AssemblyPath</code> set and pointing to the executable of the appropriate folder.</p>
  
  <p>Essentially I just want to make sure that this is the appropriate method I should be using:</p>
  
  <pre><code>private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
  {
      string InstallPath = System.IO.Path.GetDirectoryName(serviceInstaller1.Context.Parameters["AssemblyPath"]);;
  }
  </code></pre>