W.Mailh W.Mailh - 18 days ago 6
C# Question

Starting an application that is in resources C#

I am trying to run an executable that is in my resources.

Here is my current code:

System.Diagnostics.Process.Start(Properties.Resources.Application);


I know why it is not currently working. Although I do not know how to make it actually work

I am sorry if this description isn't very descriptive.

Thanks in advance

Answer

The application in the resources is just a byte[], you can't call Process.Start( on a byte[] it expects a path. Save the file to disk in a temporary folder and then execute the temporary file.

string path = GetTempFilePath();
System.IO.File.WriteAllBytes(path, Properties.Resources.Application);
System.Diagnostics.Process.Start(path);