문제

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