2012-11-12 16 views
5

प्रक्रिया। स्टार्ट को मौजूदा फ़ाइल नहीं मिल सकती है

  • मेरे पास निष्पादन योग्य फ़ाइल (C:\Test\n4.TestConsole.exe) का पथ है।
  • File.Exists(path)true देता है।
  • File.OpenRead(path) मुझे कोई समस्या नहीं होने पर इसकी स्ट्रीम मिलती है।
  • Process.Start(path) फेंकता इस संदेश के साथ एक System.ComponentModel.Win32Exception:

    प्रणाली निर्दिष्ट फ़ाइल नहीं मिल रहा।

मैं क्या गलत कर रहा हूं?

Windows 8 व्यावसायिक x64 - .नेट फ्रेमवर्क 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); 
    } 
} 
+0

फ़ाइल आप निष्पादित करने के लिए कोशिश कर रहे हैं के प्रकार क्या है? क्या यह 'निष्पादन योग्य' है? क्या आप पथ का मूल्य दिखा सकते हैं? –

+0

@WouterdeKort: एक कंसोल एप्लिकेशन। यह खुलता है और जब मैं इसे डबल-क्लिक करता हूं तो इनपुट के लिए प्रतीक्षा करता है। पथ है: 'सी: \ टेस्ट \ n4.TestConsole.exe' –

+0

पथ का मूल्य क्या है? यदि फ़ाइल System32 –

उत्तर

2

शायद यह एक गायब डीएलएल या अन्य निर्भरता है। जब आप इसे सीधे Process.Start(exe_path) के माध्यम से चलाते हैं और जब आप इसे Process.Start("cmd", "/k " + exe_path) के माध्यम से चलाते हैं तो आप PATH पर्यावरण चर की तुलना करना चाहेंगे।

1

इस प्रयास करें:

private void button1_Click(object sender, EventArgs e) 
{ 
    ProcessStartInfo psi = new ProcessStartInfo(); 
    psi.WorkingDirectory = @"C:\Test"; 
    psi.FileName = "n4.TestConsole.exe"; 
    Process.Start(psi); 
} 
संबंधित मुद्दे