如何在C#中指定路径时返回级别?

use*_*243 4 c# wix path

我想以编程方式在Visual Studio的"Extensions"文件夹中安装文件夹.我能得到的最接近的是使用VS100COMNTOOLS环境变量.我想要做的是返回"工具"文件夹中的一个级别,进入IDE /扩展,类似VS100COMNTOOLS ..\IDE\Extensions.这是我的代码:

namespace TemplatesCustomAction
{
    public class CustomActions
    {
        [CustomAction]
        public static ActionResult CustomAction1(Session session)
        {

            var vspath = Environment.GetEnvironmentVariable("VS100COMNTOOLS");

            session["VSINSTALLATIONFOLDER"] = string.Format(@"{0}\..\IDE\Extensions", vspath);



            return ActionResult.Success;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Ode*_*ded 7

用途Path.GetFullPath:

var pathWithParent = string.Format(@"{0}\..\IDE\Extensions", vspath);
session["VSINSTALLATIONFOLDER"] = Path.GetFullPath(pathWithParent);
Run Code Online (Sandbox Code Playgroud)

虽然我也宁愿使用Path.Combine:

var pathWithParent = Path.Combine(vspath, @"\..\IDE\Extensions");
Run Code Online (Sandbox Code Playgroud)