string path = @"C:\Program Files\IIS\..\Lenovo";
if(Directory.Exists(path))
{
System.Diagnostics.Process.Start("explorer.exe", path);
}
这个方法有些不完善,只能打开绝对路径,不能打开的Path中 具有../../../这样的符号这样的相对路径,在Directory.Exists中是可以判断相对路径的,但是在System.Diagnostics.Process.Start("explorer.exe", path); 打开时,却无法识别相对路径,所以需要改成
string path = @"C:\Program Files\IIS\..\Lenovo";
path = Path.GetFullPath(path);
if(Directory.Exists(path))
{
System.Diagnostics.Process.Start("explorer.exe", path);
}
本文介绍了一种使用 C# 在 Windows 系统下打开文件夹路径的方法,并针对相对路径进行了改进,确保了路径的正确解析。
1万+

被折叠的 条评论
为什么被折叠?



