tangxu
2024-10-24 c7a67ab24f476b0f8593fc61362d3bb8b262aa3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.IO;
 
namespace DPumpHydr.WinFrmUI.WenSkin.DLL
{
    public class FolderFileClass
    {
        public static void OpenFolderAndSelectFile(string fileFullName)
        {
            if (File.Exists(fileFullName))
            {
                System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe")
                {
                    Arguments = "/e,/select," + fileFullName
                };
                System.Diagnostics.Process.Start(psi);
            }
            else
            {
                string pPath = System.IO.Path.GetDirectoryName(fileFullName); //获取文件路径
                System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe")
                {
                    Arguments = "/e,/select," + pPath
                };
                System.Diagnostics.Process.Start(psi);
            }
        }
    }
}