Store value without lose them

Yakir-FX 1 Reputation point
2022-04-01T12:34:07.2+00:00

I want to use user.config NOT app.config
To store value in user.config file
Because when i relocation my app exe
It reset value in app.config

Thank you

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,636 questions
0 comments No comments
{count} votes

16 answers

Sort by: Most helpful
  1. LesHay 7,126 Reputation points
    2022-04-01T12:59:51.483+00:00

    Hi
    Maybe you could consider using the My.Settings to store the values.
    Such as:

    Make a My.Settings setting called: Loc as an Point type with any initial value (say) 0,0

    In the application Form Closing event, use My.Settings.Loc = Me.Location, and
    in the application Load event, Me.Location = My.Settings.Loc

    Those settings would save the position of the Form when the application is closed, and restore the Form to the same position when the application is next run.

    1 person found this answer helpful.
    0 comments No comments

  2. Yakir-FX 1 Reputation point
    2022-04-02T10:27:30.763+00:00

    i know that
    but
    if i move the my exe from current location in the new location i lose my settings in the "my.settings" method

    i check it now and ...

    the APP.CONFIG NOT SAVED

    USER.CONFIG working OK

    my.settings.save method is saved my values in the USER.CONFIG

    i want to store values in the app.config NOT USER.CONFIG

    0 comments No comments

  3. Jiachen Li-MSFT 27,836 Reputation points Microsoft Vendor
    2022-04-04T07:28:20.93+00:00

    Hi @Yakir-FX ,
    You may consider using the methods provided below to save your user data.
    Store it in the registry and store it in User Data folders can guarante that user data will not be lost.
    Save Settings in a .NET Winforms Application
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Yakir-FX 1 Reputation point
    2022-04-04T20:17:50.627+00:00

    Can i save settings in another app.config file instead original?

    0 comments No comments

  5. Jiachen Li-MSFT 27,836 Reputation points Microsoft Vendor
    2022-04-05T09:26:18.51+00:00

    Hi @Yakir-FX ,
    Check if the documentation below is helpful to you.
    How to: Create Application Settings
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments