Click here to Skip to main content
12,251,445 members (60,283 online)
Click here to Skip to main content

Stats

20.1K views
762 downloads
20 bookmarked
Posted

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
CFNET-AppSettings
bin
Release
CFNET-AppSettings.exe
CFNET-AppSettings.pdb
CFNET-AppSettings.vbproj.user
My Project
CFNET-AppSettings.suo

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

You may also be interested in...

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