Results 1 to 9 of 9

Thread: [RESOLVED] [2005] My.Settings Save even if re-located

  1. #1

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Resolved [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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    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

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  4. #4

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] My.Settings Save even if re-located

    Quote 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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  6. #6

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] My.Settings Save even if re-located

    Quote 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?
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  8. #8

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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
  •  



Click Here to Expand Forum to Full Width