Process.Start("explorer.exe", Path) 无法打开正确的文件夹

Process.Start("explorer.exe", Path) can't open the right folder

正如标题所说,Process.Start("explorer.exe", Path) 无法在资源管理器中打开正确的路径。

我希望打开的路径是“C:/Users/%username%/Documents/My Games/FarmingSimulator2022/mods”

实际打开的路径是“这台电脑>文档”或者可以写成“C:/Users/%用户名%/Documents”

顺便说一句,我试过@Path,没有“@”只是路径,是一样的。

我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace FS22_ModManagerCore
{
    public partial class MainWindow : Form
    {
        readonly string Username = Environment.UserName;
        public string GameDataPath;
        public string GameSettingXMLpath;
        public string ModFolder;
        
        public MainWindow()
        {
            InitializeComponent();
        }
        
        private void Btn_GetModPath_Click(object sender, EventArgs e)
        {
            GameDataPath = "C:/Users/" + Username + "/Documents/My Games/FarmingSimulator2022";
            GameSettingXMLpath = "C:/Users/" + Username + "/Documents/My Games/FarmingSimulator2022/gameSettings.xml";
            
            if (Directory.Exists(GameDataPath))
            {
                if (File.Exists(GameSettingXMLpath))
                {
                    ModFolder = GetModPath(GameDataPath, GameSettingXMLpath);
                }
                else
                {
                    MessageBox.Show("Game needs to run at least once! ExCode: 1002");
                }
            }
            else
            {
                MessageBox.Show("Gamedata folder doesn't exist! ExCode: 1001");
            }
        }
        
        public static string GetModPath(string GameDataPath, string XMLPath)
        {
            string ReturnPath = "";
            XmlDocument gameSetting = new();
            gameSetting.Load(XMLPath);
            XmlNode node = gameSetting.DocumentElement.SelectSingleNode("/gameSettings/modsDirectoryOverride");
            string IsActive = node.Attributes["active"].InnerText;
            if (IsActive == "false")
            {
                ReturnPath = GameDataPath + "/mods";
                MessageBox.Show(ReturnPath);    //DEBUG ONLY
                Clipboard.SetText(ReturnPath);  //DEBUG ONLY
                Process.Start("explorer.exe", ReturnPath);  //<<<<<< ISSUE !!!!!!!!
                return ReturnPath;
            }
            else
            {
                return ReturnPath;  //PLACE HOLDER
            }
            //string CusomPath = node.Attributes["directory"].InnerText;
        }
    }
}

Windows 路径使用 \ 而不是 /。它们通常可以互换,但并非总是如此。

这个

C:\>explorer.exe "C:\Users\David\Documents\My Games\FarmingSimulator2022\mods"

有效。所以这也是:

System.Diagnostics.Process.Start("explorer.exe", @"""C:\Users\David\Documents\My Games\FarmingSimulator2022\mods""");