需求:
需要打開windows的文件資源管理器進行瀏覽文件。
方法:
利用命令提示符(cmd)中輸入explorer.exe命令即可打開文件資源管理器
代碼實現:
1.引用
using System.Diagnostics;
2.打開資源管理器並選中該文件
Process p = new Process(); p.StartInfo.FileName = "explorer.exe"; p.StartInfo.Arguments = @" /select, C:\Users\RAPOO\Pictures\Camera Roll\wuhan.jpg"; p.Start();
效果如圖所示:
3.直接打開該文件
Process p = new Process(); p.StartInfo.FileName = "explorer.exe"; p.StartInfo.Arguments = @" C:\Users\RAPOO\Pictures\Camera Roll\wuhan.jpg"; p.Start();
效果是利用windows默認的方式打開當前指定的內容。