Get the project file path
To get the project file path, use the Path
property of the IProject
object.
public void OutputProjectFilePath(ICommandContext c, ICommandParams p)
{
//Get the project file path
var projectFilePath = c.App.Workspace.CurrentProject.Path;
c.App.Output.WriteLine("sample", projectFilePath);
}
To get the project file directory, use the GetDirectoryName()
method of System.IO.Path
.
//Get the project file path
var projectFilePath = c.App.Workspace.CurrentProject.Path;
//Get the project file directory
var dir = System.IO.Path.GetDirectoryName(projectFilePath);
App.Output.WriteLine("sample", $"Directory : {dir}");