Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Store Files In An EXE

Alright, so I'm working on programming my own installer in C#, and what I'd like to do is something along the lines of put the files in the .exe, so I can do File.Copy(file, filedir);

Or, if this isn't possible, is there another way of doing what I am attempting to do?

like image 512
S3THST4 Avatar asked Feb 08 '09 21:02

S3THST4


People also ask

How do I save a .EXE file?

Click a folder on the left side of the window to select it as the place where your file will be saved. Click Save. It's in the bottom-right corner of the screen. This will save your EXE file in your selected location under the specified name.

Where should EXE files be stored?

Applications normally should go to C:\Program Files ( %ProgramFiles% ) or to C:\Program Files (x86) ( %ProgramFiles(x86)% ) for 32-bit applications on a 64-bit version of Windows.

What files are included in an exe?

Each EXE file contains data that Windows uses to recognize, read, and run the program the file contains. This data is saved in a compiled, binary format sometimes referred to as machine code. EXE files also often contain additional program resources, such as the program's icon and its GUI graphics assets.

How is an EXE file made?

EXE files are a Windows-specific executable file format. When a user or other event triggers an executable file, the computer runs the code that the file contains. Executable files contain binary machine code that has been compiled from source code.


Video Answer


1 Answers

I wouldn't code my own installer, but if you truely want to embed files into your assembly you could use strongly typed resources. In the properties dialog of your project open up the "Resources" tab and then add your file. You'll then be able to get the file using:

ProjectNamespace.Properties.Resources.MyFile 

Then you'll be able to write the embedded resource to disk using:

System.IO.File.WriteAllBytes(@"C:\MyFile.bin", ProjectNamespace.Properties.Resources.MyFile); 
like image 50
Shawn Miller Avatar answered Oct 11 '22 11:10

Shawn Miller