using System;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
// 指定要打开的文件夹路径
string folderPath = @"C:\ExampleFolder";
// 使用 Process.Start 方法打开文件夹
try
{
Process.Start("explorer.exe", folderPath);
}
catch (Exception ex)
{
Console.WriteLine("打开文件夹失败: " + ex.Message);
}
}
}
using System; 和 using System.Diagnostics; 是必需的,前者用于基本输入输出操作,后者用于启动外部进程。string folderPath = @"C:\ExampleFolder"; 定义了要打开的文件夹路径。你可以根据需要修改这个路径。Process.Start 方法:通过调用 Process.Start("explorer.exe", folderPath); 来启动 Windows 资源管理器并打开指定的文件夹。try-catch 块用于捕获并处理可能发生的异常,例如路径无效或权限不足等情况。下一篇:opencv c#
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站