[RESOLVED] Storing Application Data Within An Application
Hey, everyone! I was wondering if it's possible to store application data within an application without storing the data in an external file. For example, in my application, the user can choose where he/she would like to store the files that the application creates. I need to make the application remember the location that the user specified.
I've tried using My.Settings to save this information, but since my application is standalone, if the location of the application changes, the My.Settings information changes as well (unless I coded it incorrectly before). I would prefer not to store this data in a .txt file or something similar. Does anyone have a solution? Thanks in advance!
Re: Storing Application Data Within An Application
Well ... you could do it ... you would need a launcher exe ... so the launcher loads your application dll / exe in a new application domain with shadow copy enabled. Then you could store whatever you liked in the file along with the executable ...
BUT.. why bother risking file corruption to your application, and this would also require having access to write to your file in the first place (which if a file is in program files for eg a standard user, by default, will not).
It is much safer to just save the info in a file and refer to the file by "somefile.someextension", this will use the working directory if it can, and if not the users document folder, and that way clearing the data would also be much easier, just delete the file!
Kris
Re: Storing Application Data Within An Application
just use this and be done with it
http://nini.sourceforge.net/
Re: Storing Application Data Within An Application
My.Settings should have worked. The values saved into the settings aren't going to be altered by moving the application somewhere else. Either I misunderstood what you were saying, or you got something off in the coding.
Re: Storing Application Data Within An Application
My.settings doesn't meet this requirement: "without storing the data in an external file"
Kris
Re: Storing Application Data Within An Application
Thanks for the replies, everyone! I was aware that My.Settings saves application data externally; however, it is in a location that a normal user would not think of looking.
I suppose the best solution would be simply to save this data externally. I normally create folders for my applications in the user's Program Files folder, and since the user expects information for programs to be stored there, it should be perfectly fine.
Thanks again for all of the help!
Re: Storing Application Data Within An Application
Quote:
Originally Posted by
hydrakiller4000
Thanks for the replies, everyone! I was aware that My.Settings saves application data externally; however, it is in a location that a normal user would not think of looking.
I suppose the best solution would be simply to save this data externally. I normally create folders for my applications in the user's Program Files folder, and since the user expects information for programs to be stored there, it should be perfectly fine.
Thanks again for all of the help!
actually thats NOT where userdata should be stored. you should be storing it under their profile somwhere (appdata, my docs, etc), not in program files
Re: Storing Application Data Within An Application
Quote:
Originally Posted by
EricPeterson87
actually thats NOT where userdata should be stored. you should be storing it under their profile somwhere (appdata, my docs, etc), not in program files
Okay, gotcha. Thanks for the help. Sorry about that.
Re: Storing Application Data Within An Application
1) you shouldn't care where the user.settings file gets saved. You just need to set hte values in my.settings and save it... and then read it back again.
2) There's a reason for not writing to the application folder in Program Files... not everyone will have access to it... Windows is starting to lock that down... and unless the user is an administrator (which you can't guarantee) then you're not going to be able to write to that location.
3) Why would your users be looking for the config file anyways? If they're editing it outside of your app... doesn't that open your app to the possibility of wrecking?
-tg
Re: Storing Application Data Within An Application
Quote:
Originally Posted by
techgnome
1) you shouldn't care where the user.settings file gets saved. You just need to set hte values in my.settings and save it... and then read it back again.
2) There's a reason for not writing to the application folder in Program Files... not everyone will have access to it... Windows is starting to lock that down... and unless the user is an administrator (which you can't guarantee) then you're not going to be able to write to that location.
3) Why would your users be looking for the config file anyways? If they're editing it outside of your app... doesn't that open your app to the possibility of wrecking?
-tg
Thanks for your input as well. I have set my UAC settings to "requireAdministrator," but I see your point. I should start to utilize the AppData folder rather than the Program Files Folder. The AppData folder also allows different users to have their own information on my applications instead of all users on the computer sharing the same information.
Thank you very much, everyone! That's certainly more than I was looking for, but the extra information was very beneficial!
Re: [RESOLVED] Storing Application Data Within An Application
Not only that... but then if your network admin allows for roaming profiles... then their settings can follow them too...
-tg