質問

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?

役に立ちましたか?

解決

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

他のヒント

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()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top