none
Safe data in my setting RRS feed

  • Question

  • Hello,

    I was wondering if there a way to save "a number for example" in my application setting and make my app able to change it but prevent the user of changing it,

    example

    i have an integer called "Time" in my setting that hold the active seconds of my app and a timer in back ground changing that number, the scope for "Time" is user so my app would be able to change it every time.

    the problem is that if some one reinstalled the Operating System or deleted the setting file that in the "..../app/local/myappname" my app will create a new one with a zero value so Time will be reset and i don't want that.

    of course if i changed the scope to application the value wont be editable.

    any ideas?!

    Thank you.

    Wednesday, October 9, 2019 4:32 AM

All replies

  • Hi AbanoubZak,

    I'm afraid it is impossible, as far as OS is re-installed with Clean-Install or the setting file is deleted. 
    If some value is saved in cloud (or in a file server) instead of local computer, it can be possible.

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Wednesday, October 9, 2019 7:31 AM
  • Hi,

    I tried what you said and I agree with Ashidacchi.

    After you delete the relevant configuration file or reinstall the system, Time will be reset unless the original file is used.

    Public Class Form1
        Dim timeuser As Integer
        Dim timeappl As Integer
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            timeuser = My.Settings.TimeUser
            timeappl = My.Settings.Time
    
            Me.Timer1.Enabled = True
            Me.Timer1.Interval = 1000
            Me.Timer1.Start()
        End Sub
    
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            My.Settings.TimeUser = timeuser
            'My.Settings.Time = timeappl
            Me.Timer1.Stop()
            My.Settings.Save()
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            timeappl += 1
            Me.TextBox1.Text = timeappl
            timeuser += 1
            Me.TextBox2.Text = timeuser
        End Sub
    End Class

    In addition, this is a document about the Application Settings Architecture that describes how the Application Settings architecture works, and explores advanced features of the architecture, such as grouped settings and settings keys.

    Hope it will be helpful.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 9, 2019 8:42 AM
    Moderator
  • ............

    the problem is that if some one reinstalled the Operating System or deleted the setting file that in the "..../app/local/myappname" my app will create a new one with a zero value so Time will be reset and i don't want that.

    of course if i changed the scope to application the value wont be editable.

    any ideas?!

    Thank you.

    Hi

    The 'Reset' would not necessarily result in a zero value, instead, it would be the value as it was when you set up the My.Settings variable .

    For example, if your variable is named TS with type as TimeSpan and value 01:02:03, then during use and in the settings storage file, the value varies according to the application use of the varialbe. When reset, the value becomes 01:02:03 again and not zero.


    Regards Les, Livingston, Scotland

    Wednesday, October 9, 2019 9:17 AM