Pergunta

The problem: Clickonce puts sub-folders of a project in a different place when used in Visual Studio vs when installed as a Clickonce application.

In Visual Studio they are under:

Directory.GetParent(Environment.CurrentDirectory).Parent

While when installed, they're under:

Environment.CurrentDirectory

Though I can check for Clickonce installation (as shown in an answer to my question here , "closed as not a real question"...) I'm worried this might break at some point - unless I understand exactly why this happens.

So what’s the correct way of getting folders' paths both when running inside Visual Studio, and when installed as Clickonce?

Nenhuma solução correta

Outras dicas

If I correctly understood your question, try to use Application.StartupPath and ApplicationDeployment.CurrentDeployment.DataDirectory as follows:

string startupPath = ApplicationDeployment.IsNetworkDeployed
    ? ApplicationDeployment.CurrentDeployment.DataDirectory :
    : Application.StartupPath;

Or just Application.StartupPath.

Or just ApplicationDeployment.CurrentDeployment.DataDirectory.

It depends on the meaning of the "Clickonce puts sub-folders of a project"

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top