Şaf*_*Gür 5 .net c# io file process
C:\Test\n4.TestConsole.exe).File.Exists(path)回报true.File.OpenRead(path) 给我带来了它没有问题的流.Process.Start(path)抛出System.ComponentModel.Win32Exception这条消息:
该系统找不到指定的文件.
Windows 8 Professional 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);
}
}
Run Code Online (Sandbox Code Playgroud)
这可能是缺少 DLL 或其他依赖项。您可能想比较直接通过运行它Process.Start(exe_path)和通过 运行它时的 PATH 环境变量Process.Start("cmd", "/k " + exe_path)。
| 归档时间: |
|
| 查看次数: |
6482 次 |
| 最近记录: |