Изучение различных методов открытия проводника Windows в определенном месте на C#

Чтобы открыть проводник Windows в определенном месте в C#, вы можете использовать различные методы. Вот несколько подходов:

Метод 1: Process.Start

string folderPath = @"C:\your\folder\path";
System.Diagnostics.Process.Start("explorer.exe", folderPath);

Метод 2: ShellExecute

[DllImport("shell32.dll")]
public static extern IntPtr ShellExecute(
    IntPtr hwnd,
    string lpOperation,
    string lpFile,
    string lpParameters,
    string lpDirectory,
    int nShowCmd
);
string folderPath = @"C:\your\folder\path";
ShellExecute(IntPtr.Zero, "explore", folderPath, null, null, 1);

Метод 3: Process.StartInfo

string folderPath = @"C:\your\folder\path";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "explorer.exe";
process.StartInfo.Arguments = folderPath;
process.Start();

Метод 4. Использование Windows Script Host (требуется добавление ссылки на «Объектную модель Windows Script Host» в ваш проект)

string folderPath = @"C:\your\folder\path";
dynamic shell = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
shell.Explore(folderPath);

Метод 5: использование WshShell (требуется добавление ссылки на «Microsoft.VisualBasic» в ваш проект)

string folderPath = @"C:\your\folder\path";
dynamic shell = new Microsoft.VisualBasic.Interaction();
shell.ShellExecute(folderPath, "explore", "", "", 1);