Currently I do the following:
Here is the code I use:
byte[] exeFile =ExeSecure.Properties.Resources.ReqCheck;
//2) Create file to be deleted on close
FileStream aFile = new FileStream(@"c:\reco.exe", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite, 20000, FileOptions.DeleteOnClose);
//3) Write Exe file content to HDD
aFile.Write(exeFile, 0, exeFile.Length);
aFile.Flush();
Thread.Sleep(100); //Wait a while for file to be flushed
while (!File.Exists(@"c:\reco.exe")); //Make sure file is there on HDD
Process.Start("C:\reco.exe");//Start file , this always fails.
Maybe this is just a typo in your question, but the path in Process.Start
is incorrect. You are missing the @
sign:
Process.Start(@"C:\reco.exe");