|
-
Mar 12th, 2009, 09:25 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] My.Settings Save even if re-located
I always wondered, but is there a way to get My.Settings to save even when you move a program, such as copy it to another location? Maybe its just me but whenever I use My.Settings in an application, copying it into a different directory will reset all the settings, which kind of sucks.
Is there anyway to get the values to stay in the application no matter what? If not My.Settings, than is there any way to store a value to a program so that you don't have to use external files, but so that it will remember the settings even when copied?
And I don't mean things like Registry Values and external .txts, I want to keep it all-in-one.
-
Mar 12th, 2009, 11:02 PM
#2
Re: [2005] My.Settings Save even if re-located
The My.Settings Will Save the Contents in XML File in the following location
<c:\Documents and Settings>\<username>\[Local Settings\]Application Data\<companyname>\<appdomainname>_<eid>_<hash>\<verison>.
If you remove this file then the settings will not be reloaded
Refer
Please mark you thread resolved using the Thread Tools as shown
-
Mar 13th, 2009, 03:06 AM
#3
Re: [2005] My.Settings Save even if re-located
Hey,
There is nothing to stop you storing the settings in something other than My.Settings. For instance, create your own class, and save all the settings in there, then when the user hits save, serialize that class out to an XML file, or a binary file, and store it in the same location as the exe. That way, when you move the application, i.e. copying it to another folder, you will be taking the information with you.
Have a look at the serialization link in my signature for information on how to do this.
Hope this helps!!
Gary
-
Mar 13th, 2009, 03:28 PM
#4
Thread Starter
Fanatic Member
Re: [2005] My.Settings Save even if re-located
 Originally Posted by danasegarane
The My.Settings Will Save the Contents in XML File in the following location
<c:\Documents and Settings>\<username>\[Local Settings\]Application Data\<companyname>\<appdomainname>_<eid>_<hash>\<verison>.
If you remove this file then the settings will not be reloaded
Refer
I'm not doing anything to the file, I want to use the same one though. I think its stupid that VB has the program create a new My.Settings if you so much as put the program into a different folder. I read the article but didn't see anything about keeping the same one.
There is nothing to stop you storing the settings in something other than My.Settings. For instance, create your own class, and save all the settings in there, then when the user hits save, serialize that class out to an XML file, or a binary file, and store it in the same location as the exe. That way, when you move the application, i.e. copying it to another folder, you will be taking the information with you.
I know there are other ways but when you say serialize it to an outside file, that would mean you'd have two files, and I'm looking for an all-in-one type program where you can move just the program somewhere and keep the same settings without having to carry around a settings file.
-
Mar 13th, 2009, 03:48 PM
#5
Re: [2005] My.Settings Save even if re-located
Hey,
If you move the exe, then the My.Settings file is always going to get re-created, since the path location has changed, hence the eid (as danasegarane mentioned) has changed. You can find out more information about that here.
http://msdn.microsoft.com/en-us/library/ms379611.aspx
If I understand correctly what you mean, then you would have to essentially "hard code" the location for the settings file, rather then relying on the My.Settings default behaviour.
Gary
-
Mar 13th, 2009, 04:24 PM
#6
Thread Starter
Fanatic Member
Re: [2005] My.Settings Save even if re-located
 Originally Posted by gep13
If I understand correctly what you mean, then you would have to essentially "hard code" the location for the settings file, rather then relying on the My.Settings default behaviour.
Gary
Is there anyway to get My.Settings to use the same Data regardless of the location? If not then I guess "hard code" is the only thing that fits what I want, any suggestions on how to do something like that?
-
Mar 14th, 2009, 04:08 AM
#7
Re: [2005] My.Settings Save even if re-located
Hey,
Just so we are clear, you are talking about User scoped My.Settings, and not application scoped ones, yes?
As far as I am aware, there is no way to specify the location of the files used with My.Settings, these are handled automatically. If you are wanting to fix the location, then you are going to need to serialize the information to a particular location, and read and write to that location each time.
Gary
-
Mar 14th, 2009, 01:39 PM
#8
Thread Starter
Fanatic Member
Re: [2005] My.Settings Save even if re-located
Yes I meant user scoped. I guess I'll just have to work with keeping the settings in an external location, I'll look at serialization some more.
-
Mar 14th, 2009, 01:41 PM
#9
Re: [RESOLVED] [2005] My.Settings Save even if re-located
Hey,
It's quite simple to do. The link in my signature has a full example.
You would need to expand on it to serialize different versions for each user, but it shouldn't be too difficult.
Gary
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
|