|
-
Jan 8th, 2012, 10:41 PM
#1
Thread Starter
Member
[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!
-
Jan 8th, 2012, 11:02 PM
#2
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
-
Jan 9th, 2012, 09:49 AM
#3
Hyperactive Member
Re: Storing Application Data Within An Application
just use this and be done with it
http://nini.sourceforge.net/
-
Jan 9th, 2012, 11:14 AM
#4
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.
My usual boring signature: Nothing
 
-
Jan 9th, 2012, 10:11 PM
#5
Re: Storing Application Data Within An Application
My.settings doesn't meet this requirement: "without storing the data in an external file"
Kris
-
Jan 9th, 2012, 10:35 PM
#6
Thread Starter
Member
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!
-
Jan 10th, 2012, 01:15 AM
#7
Hyperactive Member
Re: Storing Application Data Within An Application
 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
-
Jan 10th, 2012, 03:56 AM
#8
Thread Starter
Member
Re: Storing Application Data Within An Application
 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.
-
Jan 10th, 2012, 08:18 AM
#9
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
-
Jan 10th, 2012, 11:51 AM
#10
Thread Starter
Member
Re: Storing Application Data Within An Application
 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!
-
Jan 10th, 2012, 11:58 AM
#11
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|