5

VisualStudioの「Extensions」フォルダーにプログラムでフォルダーをインストールしたい。私が得ることができる最も近いものは、VS100COMNTOOLS環境変数を使用することです。私がやりたいのは、「ツール」フォルダから1レベル戻り、VS100COMNTOOLS .. \ IDE\Extensionsのような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;
        }
    }
}
4

1 に答える 1

8

使用Path.GetFullPath

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

私もむしろ使用したいのですがPath.Combine

var pathWithParent = Path.Combine(vspath, @"\..\IDE\Extensions");
于 2012-12-12T16:20:29.960 に答える