Question

I have a WPF ClickOnce deployed application. Is there any way to get what directory was specified in the Publish configuration? ie. I specified C:\MyLocation as the Publishing Folder Location. Is it possible to retrieve this directory path via code in the application itself?

Était-ce utile?

La solution

Try the following:

if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
     var deploy = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
     var uri = deploy.ActivationUri;
     // Also:
     //deploy.DataDirectory
     //deploy.UpdateLocation
}

For more documentation:

http://msdn.microsoft.com/en-us/library/system.deployment.application.applicationdeployment(v=vs.100).aspx

Autres conseils

In case anyone else finds this later, like I did, this worked better for me:

Dim installExePath As String = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.UpdateLocation.LocalPath
installExePath = System.IO.Path.GetDirectoryName(installExePath) & "\setup.exe"
'MsgBox("About to start " & installExePath)
Process.Start(installExePath)
Application.Exit()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top