1

I'm currently working on a small project where I have a list of lists of objects, which I need to store between program executions. The scale of the project is in my opinion not large enough to start developing an external DB-solution, so I would like to store the data inside the executable, so the end-user does not have to keep track of multiple files. Is this possible at all? I've been thinking about embedding the file as a resource, but as I have read, it is not possible to edit this resource file without recompiling the project, so this is not a solution. Alternatively I have read about Alternate Data Streams, but I don't know if it is a good idea to edit the executable this way?

So all in all I need the executable to store data between executions, without the need for managing other files.

I hope you are able to help me.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ZymLink
  • 157
  • 1
  • 1
  • 8
  • 1
    Editing the exe is not a good dea; most users shouldnt have write access to programs, and it breaks signing etc. a secondary file, automatically loaded by the app from the user's profile area is preferred. App-settings would do this nicely. – Marc Gravell Aug 19 '12 at 13:16
  • App-settings unfortunately doesn't solve the problem, since i want the program to be as portable as possible. Eg. a user copies the executable to a portable media and inserts this media in another computer. If all the data is stored in app-settings, the data is lost. I need the data to follow the executable no matter where and how you access it. My current solution is XML-serialization of all objects, but that generates the problem with an executable and a data file to keep track of, which i want to avoid. Don't know if it is at all possible? – ZymLink Aug 20 '12 at 13:09
  • not unless you use cloud storage or similar. Don't edit your own exe. – Marc Gravell Aug 20 '12 at 13:38

1 Answers1

0

I believe Application Settings are the way to go here.

More explained at Best practice to save application settings in a Windows Forms Application

Community
  • 1
  • 1
vvondra
  • 3,022
  • 1
  • 21
  • 34