G
Guest
I was given the following code in response to a request to retrieving the
Web Root for a Project while at design time. However this does not do what I
need it to do. I am looking for the Current Project (which i assume is
objProject) and I am looking for its "Project Folder" ?
The Solution I was given is very buggy as it randomly gives different
project folders directories, or the last saved directory. for example i was
editng an html that was not part of the project about 7 hours ago. When I
went to Webform1.aspx it showed the path to the Html file i saved (even
though it was not a part of the project and had been edited and taken care
of along time ago)
object objCodeDomProvider =
((Hashtable)objServiceContainerServices)[domType];
EnvDTE.ProjectItem objProjectItem =
(EnvDTE.ProjectItem)objCodeDomProvider.GetType().InvokeMember
( "projectItem",
BindingFlags.Instance |BindingFlags.NonPublic| BindingFlags.GetField,
null,
objCodeDomProvider,
new object[] { }
);
// Create an EnvDTE.Project object
EnvDTE.Project objProject = objProjectItem.ContainingProject;
EnvDTE.Solution objSolution = objProject.DTE.Solution;
StringBuilder TheBuilder = new StringBuilder();
return objProject.DTE.ActiveDocument.Path;
Web Root for a Project while at design time. However this does not do what I
need it to do. I am looking for the Current Project (which i assume is
objProject) and I am looking for its "Project Folder" ?
The Solution I was given is very buggy as it randomly gives different
project folders directories, or the last saved directory. for example i was
editng an html that was not part of the project about 7 hours ago. When I
went to Webform1.aspx it showed the path to the Html file i saved (even
though it was not a part of the project and had been edited and taken care
of along time ago)
object objCodeDomProvider =
((Hashtable)objServiceContainerServices)[domType];
EnvDTE.ProjectItem objProjectItem =
(EnvDTE.ProjectItem)objCodeDomProvider.GetType().InvokeMember
( "projectItem",
BindingFlags.Instance |BindingFlags.NonPublic| BindingFlags.GetField,
null,
objCodeDomProvider,
new object[] { }
);
// Create an EnvDTE.Project object
EnvDTE.Project objProject = objProjectItem.ContainingProject;
EnvDTE.Solution objSolution = objProject.DTE.Solution;
StringBuilder TheBuilder = new StringBuilder();
return objProject.DTE.ActiveDocument.Path;