问题
I want to access the path to currently open solution in Visual Studio from a vsix project. How can I get that?
This thread tells if a solution is open or not but gives nothing about the path of the opened solution
回答1:
I use this:
public string GetInitialFolder(DTE dte)
{
if (!dte.Solution.IsOpen)
return null;
return System.IO.Path.GetDirectoryName(dte.Solution.FullName);
}
But expect it to error, sometimes it cannot return a path!
回答2:
I would suggest to avoid EnvDTE as much as possible when developing packages and use native services whenever possible. In this case IVsSolution.GetSolutionInfo
来源:https://stackoverflow.com/questions/31292155/acessing-currently-opened-solution-in-a-vsix-project