Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Integrating data (pictures) into .exe

this is my first question here.

I've made a small quiz project about the 199 world's states via Visual Studio C#. therefor I collected all flags of every country and put them into a folder - you can imagine that i collected MANY.

To run my current project i need the folder with all these .gif images - otherwise the startup will end in a fatal error. :-(

My question is if it is possible to integrate the images into my .exe file so that i can run it without that nasty folder. (Also important for future project with even more content!)

And if it is possible - how? It would also be nice if you let me know how to use the images - what pathes they have got etc ... =)

Thanks in advance!

Robbepop

like image 594
Robbepop Avatar asked Jan 17 '11 18:01

Robbepop


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr. Stroustroupe.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What is C language basics?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.


1 Answers

You can add a resource file to your application, by going to

Project >> Your Project Properties >> Resources >> Create A Resource File.

You can then simply add any image to your application and reference it via your code. Select Images from the drop down on the top of the menu, and then click Add Resource >> From existing file.

After you save your resource file, you can then access your images via code, e.g.

> Image img =
> YourProject.Properties.Resources.Image1

However, with the number of images you have, and what I would believe you are using them for, I would suggest using a Image List, which you can add all of your images to, and access them via their key or index. e.g.

Image img = imageList1[0];  

Or

Image img = imageList1["US"];

This can be found in your toolbox.

like image 174
George Johnston Avatar answered Sep 24 '22 02:09

George Johnston