System.Diagnostics.Process.Start(「explorer.exe」,path)の不完全な点
604 ワード
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);
}