GetSelectedPath() public static method

public static GetSelectedPath ( DTE2 dte ) : string
dte DTE2
return string
        private void OpenFolderInVs(object sender, EventArgs e)
        {
            try
            {
                var    dte  = (DTE2)ServiceProvider.GetService(typeof(DTE));
                string path = ProjectHelpers.GetSelectedPath(dte, _options.OpenSolutionProjectAsRegularFile);

                if (!string.IsNullOrEmpty(path))
                {
                    int line = 0;

                    if (dte.ActiveDocument?.Selection is TextSelection selection)
                    {
                        line = selection.ActivePoint.Line;
                    }

                    OpenVsCode(path, line);
                }
                else
                {
                    MessageBox.Show("Couldn't resolve the folder");
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Esempio n. 2
0
        private void OpenFolderInVs(object sender, EventArgs e)
        {
            try
            {
                var    dte  = (DTE2)ServiceProvider.GetService(typeof(DTE));
                string path = ProjectHelpers.GetSelectedPath(dte);

                if (!string.IsNullOrEmpty(path))
                {
                    OpenVsCode(path);
                }
                else
                {
                    MessageBox.Show("Couldn't resolve the folder");
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }