Most of the time, we may be adding few extenders to our windows application to deal with various requirements. One of our requirement is to get the current directory path to the extender and display the extended property value accordingly.
For accessing the current directory path, we used the EnvDTE.
public string GetCurrentDirectoryPath()
Project currentProject = null;
DTE dte = this.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
if (dte == null)
if (dte.ActiveDocument != null &&dte.ActiveDocument.ActiveWindow !=null &&dte.ActiveDocument.ActiveWindow.Project !=null )
currentProject = dte.ActiveDocument.ActiveWindow.Project;
Array solutions = dte.ActiveSolutionProjects;
string projectAssemblyName = string .Empty;
if (solutions.Length > 0)
currentProject = solutions.GetValue(0) as Project ;
string path = System.IO.Path .GetDirectoryName(currentProject.FullName);
This entry was posted in C#
and tagged Dir
. Bookmark the permalink