我想我找到了一个bug。在我看来,Process.Start运行错误的目录。 要进行测试,创建默认控制台应用程序模板,并粘贴如下:System.Diagnostics.Process.Start()打开/运行错误的目录?
using System;
using System.Diagnostics;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
bool test = false;
DirectoryInfo root = Directory.CreateDirectory(
System.IO.Path.Combine(Directory.GetCurrentDirectory(), "folder"));
DirectoryInfo bug = Directory.CreateDirectory(
System.IO.Path.Combine(root.FullName, "bug"));
DirectoryInfo bugDotCom = Directory.CreateDirectory(
System.IO.Path.Combine(root.FullName, "bug.com"));
ProcessStartInfo bugPSI = new ProcessStartInfo(bug.FullName);
ProcessStartInfo bugDotComPSI = new ProcessStartInfo(bugDotCom.FullName);
if (test)
{
Console.WriteLine(bug.FullName);
Process.Start(bugPSI);
}
else
{
Console.WriteLine(bugDotCom.FullName);
Process.Start(bugDotComPSI);
}
Console.ReadKey();
}
}
}
时可变测试设置为false,bug.com目录应该被打开,否则错误目录。然而,这个例子表明,总是bug.com被打开(不管是测试变量) - 至少对我而言。 有什么问题?我错过了一些东西,或者那只是一个错误?
如果将'com'更改为'Random',会发生什么? **编辑**:如果没有'bug.com',它可以工作。 – SLaks 2011-04-03 23:55:06
+1,看起来像一个错误。资源管理器不应该在这里使用PATHEXT。您可能想要使用Connect报告它。 – SLaks 2011-04-04 00:13:48