Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Compact Framework Configuration XML File Read & Write like appSettings

, 13 Jan 2010 CPOL
How to use an XML file to read and write aplication settings in a Window Mobile development
CFNET--AppSettings.zip
CFNET-AppSettings
CFNET-AppSettings
bin
Release
CFNET-AppSettings.exe
CFNET-AppSettings.pdb
CFNET-AppSettings.vbproj.user
My Project
CFNET-AppSettings.suo
CFNET-AppSettings.zip

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)

Share

About the Author

No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 13 Jan 2010
Article Copyright 2010 by Alejandro Barrada
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid