Are there any guides for saving data from a C# application to its own external project file such as embedding images, etc. to be loaded later? Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can embed just about any type of data in a .NET assembly and read from it, but you cannot modify your own executable(s), and even if you could, that would be a bad idea. For one, think about how trippy that would be for an antivirus program seeing an EXE suddenly change while running.
If you have metadata (images or any other type of file) you need to read and write, just use the filesystem. The
Environmentclass has functions that will return well-known per application and per-user locations where you can store anything you want.Edit
I’m not sure if this is what you’re asking, but here it goes. Let’s say you have a class called
Documentthat contains some text and some images, which are rendered in some unspecified way. So basically it would look like this:Not sure what
Imageis, I just made it up. Using the .NET serialization functions you can turn this into a byte stream:Which you can then save to a file. Then you can load the file and turn it into a document:
This is very rough obviously, but you can serialize and deserialize most objects in .NET, including some of the built-in types as well.