473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to include an executable in the c# console project

Mo
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
Nov 28 '07 #1
3 7224
Mo,

Not that I know of. You would have to include the other executable
separately.

If the executable is self-contained, and has no dependencies that you
need to ship, then you could include the executable as a resource in your
main executable, then extract and save it to disk and execute it when
needed. It would still require some cross-process communication to get the
results, but you would have one executable you have to ship.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mo" <le******@yahoo.comwrote in message
news:aa**********************************@d61g2000 hsa.googlegroups.com...
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

Nov 28 '07 #2
"Mo" <le******@yahoo.comwrote in message
news:aa**********************************@d61g2000 hsa.googlegroups.com...
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

One .exe cannot *call* another exe, one .exe can only *start* another .exe,
and this requires both .exe to be separate PE files.

Willy.

Nov 28 '07 #3
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);
}
Nov 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: mescaline | last post by:
Hi, Suppose a_file.cpp contains a function a_function() Now to include it in main_file.cpp I just do #include "a_file.cpp" and I'm all set. i recently came across this seemingly roundabout...
44
by: Neil Cerutti | last post by:
In Rob Pike's style guide he urges the following: Simple rule: include files should never include include files. If instead they state (in comments or implicitly) what files they need...
4
by: FrzzMan | last post by:
The subject may sound a lil dumb :D But my problem is: When my app run, it'll check if a specific file existed or not, if existed it's OK, if not it will create default file. I want to...
1
by: Steve Richter | last post by:
I am working from the C++ .net step by step book ... my project compiles and runs as a console application: #include "stdafx.h" #using <mscorlib.dll> #using <System.dll> #using...
3
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
11
by: Bit byte | last post by:
I want to create a GUI-less windows executable (i.e. an executable that has no gui) and no console. The idea is to have this running as a kind of daemon (it can't be a service, for reasons I wont...
1
by: mohaaron | last post by:
Hello all, This might seem like an odd question but I would like to know how to create a standalone executable. I'm using vs.net 2005 and the closest project template I can find for what I want...
2
by: orsula | last post by:
Hi all, First I would like to say that I'm thrilled to be a part of this great news group! I'm kinda new to c#, yet I have a tight schedule to deliver my project (ain't it always like that :)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.