Harjatin
Harjatin

Reputation: 1355

Acessing currently opened solution in a vsix project

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

Upvotes: 7

Views: 2325

Answers (2)

Carlos Quintero
Carlos Quintero

Reputation: 4414

I would suggest to avoid EnvDTE as much as possible when developing packages and use native services whenever possible. In this case IVsSolution.GetSolutionInfo

Upvotes: 7

ErikEJ
ErikEJ

Reputation: 41819

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!

Upvotes: 1

Related Questions