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
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
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!
I would suggest to avoid EnvDTE as much as possible when developing packages and use native services whenever possible. In this case IVsSolution.GetSolutionInfo
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!
© 2022 - 2024 — McMap. All rights reserved.