プロジェクトファイルのパスを取得する
プロジェクトファイルのパスを取得するには、IProject
オブジェクトのPath
プロパティを用います。
public void OutputProjectFilePath(ICommandContext c, ICommandParams p)
{
// プロジェクトファイルのパスを取得します
var projectFilePath = c.App.Workspace.CurrentProject.Path;
c.App.Output.WriteLine("sample", projectFilePath);
}
プロジェクトファイルのディレクトリを取得するには、System.IO.Path
のGetDirectoryName()
メソッドを用います。
// プロジェクトファイルのパスを取得します
var projectFilePath = c.App.Workspace.CurrentProject.Path;
// プロジェクトファイルのディレクトリを取得します
var dir = System.IO.Path.GetDirectoryName(projectFilePath);
App.Output.WriteLine("sample", $"Directory : {dir}");