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?

没有正确的解决方案

其他提示

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"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top