- 我有一个可执行文件 (
C:\Test\n4.TestConsole.exe
) 的路径。 File.Exists(path)
返回true
。File.OpenRead(path)
给我它的流没有问题。Process.Start(path)
抛出System.ComponentModel.Win32Exception
此消息:该系统找不到指定的文件。
Windows 8 专业版 x64 - .NET Framework 4.5
编辑:这是代码。
public partial class Form1 : Form
{
public string Path { get; set; }
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// I put a breakpoint here and verify the Path's value is
// C:\Test\n4.TestConsole.exe.
// File.Exists returns true.
MessageBox.Show(File.Exists(Path));
// File.OpenRead doesn't throw an exception.
using (var stream = File.OpenRead(Path)) { }
// This throws the exception.
Process.Start(Path);
}
}