Process.Start non riesce a trovare un file esistente
- Ho il percorso di un file eseguibile (
C:\Test\n4.TestConsole.exe
). File.Exists(path)
restituiscetrue
.File.OpenRead(path)
mi ottiene il suo flusso senza alcun problema.Process.Start(path)
getta unSystem.ComponentModel.Win32Exception
con questo messaggio:Il sistema non trova il file specificato.
Windows 8 Professional x64 - .NET Framework 4,5
Edit: Ecco il codice.
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);
}
}
Qual è il tipo di file che si sta tentando di eseguire? È "eseguibile"? Puoi mostrare il valore del percorso? –
@WouterdeKort: un'applicazione console. Si apre e attende un input quando faccio doppio clic su di esso. Il percorso è: 'C: \ Test \ n4.TestConsole.exe' –
Qual è il valore del percorso? È necessario utilizzare il percorso completo del file se il file non è in System32 –