Acessing currently opened solution in a vsix project

你离开我真会死。 提交于 2021-02-07 12:54:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!