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)
return null;
if (dte.ActiveDocument != null &&dte.ActiveDocument.ActiveWindow !=null &&dte.ActiveDocument.ActiveWindow.Project !=null )
{
currentProject = dte.ActiveDocument.ActiveWindow.Project;
}
else
{
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);
return path;
}
Pingback: Absolute Path from Relative Path | Ambilykk's Blog
Pingback: Absolute Path from Relative Path | ASP.NET tutorials for beginners
so how to call that as string