Click here to Skip to main content
15,885,365 members
Articles / Mobile Apps / Windows Mobile

Compact Framework Configuration XML File Read & Write like appSettings

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
13 Jan 2010CPOL2 min read 36.9K   922   20  
How to use an XML file to read and write aplication settings in a Window Mobile development

Public Class Form1
    Dim MyAppSettings As New MyAppSettings

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadSettings()

    End Sub

    Sub LoadSettings()
        Dim UserName As String = MyAppSettings.UserName
        If UserName.Trim.Equals("") Then UserName = "Please type your Name"
        txtUserName.Text = UserName
        lblLoginCount.Text = MyAppSettings.LoginCount + 1
        lblFileCreated.Text = CType(MyAppSettings.ListItems("FileCreated"), Date).ToShortDateString
        If Not IsNothing(MyAppSettings.ListItems("FileModified")) AndAlso Not MyAppSettings.ListItems("FileModified").Equals("") Then _
        lblFileModified.Text = CType(MyAppSettings.ListItems("FileModified"), Date).ToShortDateString

    End Sub

    Sub SaveSettings()
        MyAppSettings.UserName = txtUserName.Text
        MyAppSettings.LoginCount += 1
        MyAppSettings.ListItems("FileModified") = Now
        MyAppSettings.SaveXmlCurrentConfiguration()


    End Sub



    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        SaveSettings()
        LoadSettings()
    End Sub

    Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
        LoadSettings()
    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions