On Nov 28, 12:19 pm, Mo <le_mo...@yahoo.comwrote:
Hi,
Is there a way to include an executable (xxx.exe) file inside a c#
console project so that the resulting project binary have only one
final executable file? My c# console application is calling another
Executable (exe) which I am trying to include in my project so I can
only have one file for the executable. Any ideas?
Mo
If I'm reading you correctly you may be able to include the 2nd
executable in the 1st project as an embedded resource. The 1st
executable could read the embedded resource, write it out to a file,
then execute it. Something along the lines of:
static void Main(string[] args)
{
string outFile = args[0];
Assembly asm = Assembly.GetExecutingAssembly();
Stream stream =
asm.GetManifestResourceStream("EmbeddedEXETest.Emb eddedEXETest.exe");
byte[] buf = new byte[4096];
FileStream fOut = new FileStream(outFile, FileMode.Create);
int bytesRead = 0;
while ( (bytesRead=stream.Read(buf, 0, buf.Length)) 0 )
fOut.Write(buf, 0, bytesRead);
stream.Close();
fOut.Close();
Console.WriteLine("Output written to {0}", outFile);
}