문제

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