在 c# 中打开资源管理器进程

本文关键字:资源管理器 进程 | 更新日期: 2023-09-27 18:36:25

我目前遇到一个问题,我需要创建一个打开资源管理器的应用程序.exe 凭据正确后的过程。

我决定做的是在搜索数据库并且信息正确后执行以下操作。

        Process process = new Process();
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        startInfo.FileName = "cmd.exe";
        startInfo.Arguments = "explorer.exe";
        process.StartInfo = startInfo;
        process.Start();

应用程序打开CMD但不启动资源管理器功能后。

我做错了什么还是有其他方法.

谢谢

在 c# 中打开资源管理器进程

我不确定为什么要尝试从新的命令行进程打开 Windows 资源管理器,只需直接启动资源管理器:

Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = false; //I don't need it, but the OP did.
startInfo.FileName = "explorer.exe";
startInfo.Arguments = "";
process.StartInfo = startInfo;
process.Start();

已验证在 .NET 4.5、Windows 7 上工作