How to compile all files to one exe?
Add that as an embedded resource.
Inside Visual Studio :
- Go to Solution Explorer,
- Right click the image,
- GO to Build Actions: Select Embedded Resource.
You will have that image inside the exe. Later you can use Reflection and get the image when you run your application.
========= Getting the Embedded image from the Application =========
First solve the first problem: by putting images as embedded resource.
Second problem: Access the images by using Reflection:
private void Form1_Load(System.Object sender, System.EventArgs e)
{
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream myStream = myAssembly.GetManifestResourceStream("EmbeddingExample.image1.bmp");
Bitmap image = new Bitmap(myStream);
this.ClientSize = new Size(image.Width, image.Height);
PictureBox pb = new PictureBox();
pb.Image = image;
pb.Dock = DockStyle.Fill;
this.Controls.Add(pb);
}
Borrowed Source Code from here:
You can put all your files/images into the exe as Embedded Resources.
See How to embed and access resources by using Visual C# (This link currently 404s)
ilmerge is only for merging .net CLR binaries together, usually for bundling libraries into your main executable.
For things like art assets, you want to embed them as resources into your application. From a resource you can get a stream which lets you work with the data as if it were in a file.
See this MSDN article for information on embedding resources: http://support.microsoft.com/kb/319292