管理

文件资源管理器定位操作类 - C#小函数类推荐

Posted on 2025-02-18 22:37  lzhdim  阅读(10070)  评论(0)    收藏  举报
/***

    文件资源管理器定位操作类

    Austin Liu 刘恒辉
    Project Manager and Software Designer

    E-Mail: lzhdim@163.com
    Blog:   http://lzhdim.cnblogs.com
    Date:   2024-01-15 15:18:00

    使用方法例子:
        OpenInExplorerUtil.OpenFileInExplorer(Application.ExecutablePath());

***/

namespace Lzhdim.LPF.Utility
{
    using System.Diagnostics;

    /// <summary>
    /// 文件资源管理器定位操作类
    /// </summary>
    public sealed class OpenInExplorerUtil
    {
        /// <summary>
        /// 用文件资源管理器定位文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        public static void OpenFile(string filePath)
        {
            Process.Start("explorer.exe", $"/select, \"{filePath}\"");
        }

        /// <summary>
        /// 用文件资源管理器定位文件夹
        /// </summary>
        /// <param name="folderPath">文件夹路径</param>
        public static void OpenFolder(string folderPath)
        {
            Process.Start("explorer.exe", folderPath);
        }
    }
}

 

Copyright © 2000-2022 Lzhdim Technology Software All Rights Reserved