سؤال

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