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.
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.
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 ServiceInstaller
control as well. Both have the Context
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 TargetDir
property set but that hasn't been the case. I am however seeing AssemblyPath
set and pointing to the executable of the appropriate folder.
Essentially I just want to make sure that this is the appropriate method I should be using:
private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
{
string InstallPath = System.IO.Path.GetDirectoryName(serviceInstaller1.Context.Parameters["AssemblyPath"]);;
}