File Cannot Be Specified ErrorAnswered

I wrote this method to check if my app requires an update. I keep getting an error at the line:             var num = Process.Start(wyUpdatePath, "/quickcheck /justcheck /noerr"); that says “The system cannot find the file specified.”

I am not sure why this is however since the file does exist in the project and my WriteLine statement has been printing the correct file path.

public void GetModuleDirectory()
       {
           var wyUpdatePath = Path.Combine(Directory.GetCurrentDirectory(), "wyUpdate.exe");
           Console.WriteLine("BlueBeetle: " + wyUpdatePath);
           var num = Process.Start(wyUpdatePath, "/quickcheck /justcheck /noerr");
           Console.WriteLine("GreenGiraffe: " + "wyUpdate.exe started"); 
           num.WaitForExit(); 
           Console.WriteLine("GreenGiraffe: " + "wyUpdate.exe exited, ExitCode: " +                         num.ExitCode.ToString());
           num.WaitForExit();
           if (num.ExitCode == 2)
           {
               ReadyToBeInstalled();
           }
           else if (num.ExitCode == 1)
           {
               automaticUpdater1.Visible = false;
               helpTextView.Visible = true;
               helpTextView.Text = "There was an error with the installation.";
           }
           else if(num.ExitCode == 0)
           {
               automaticUpdater1.Visible = false;
               helpTextView.Visible = true;
               helpTextView.Text = "There are no updates to be installed.";
           }
       }

Answer

It sounds like it's telling you exactly what the problem is. It can't be found. Add breakpoints and figure where you went wrong.

But if the code is giving the correct file path to the wyUpdate.exe then why would it be giving that error?

I ran the path through the command prompt too and the file opens and runs, so it's not an instance of the file not existing or not working. Is there something specific I have to do to access a wyUpdate.exe in Visual Studio?

Answer

Likely an error with your usage of Process.Start(). Google the docs, and debug your usage.