using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 智能仓储WCS管理系统 { /// /// 文件夹操作 /// public static class Folder { /// /// 打开目录 /// /// 目录路径(比如:C:\Users\Administrator\) public static void OpenFolder(string folderPath) { if (string.IsNullOrEmpty(folderPath)) return; Process process = new Process(); ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe"); psi.Arguments = folderPath; process.StartInfo = psi; try { process.Start(); } catch (Exception ex) { throw ex; } finally { process?.Close(); } } /// /// 打开目录且选中文件 /// /// 文件的路径和名称(比如:C:\Users\Administrator\test.txt) public static void OpenFolderAndSelectedFile(string filePathAndName) { if (string.IsNullOrEmpty(filePathAndName)) return; Process process = new Process(); ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe"); psi.Arguments = "/e,/select," + filePathAndName; process.StartInfo = psi; //process.StartInfo.UseShellExecute = true; try { process.Start(); } catch (Exception ex) { throw ex; } finally { process?.Close(); } } } }