Process XML Files Region

This code region contains subroutines to read and write the form settings to XML files.

#Region " Process XML files - Read and write XML files."
 
    Private Sub WriteFormSettingsXmlFile()
        'Write form settings
 
        Dim settingsData = <?xml version="1.0" encoding="utf-8"?>
                           <!---->
                           <!--Form settings for Import Text Into Database form.-->
                           <FormSettings>
                               <Left><%= Me.Left %></Left>
                               <Top><%= Me.Top %></Top>
                               <Width><%= Me.Width %></Width>
                               <Height><%= Me.Height %></Height>
                               <!---->
                           </FormSettings>
 
        If Trim(Main.ProjectPath) <> "" Then 'Write the Form Settings file in the Project Directory
            settingsData.Save(Main.ProjectPath & "\" & "FormSettings_" & Me.Text & ".xml")
        Else 'Write the Form Settings file in the Application Directory
            settingsData.Save(Main.ApplicationDir & "\" & "FormSettings_" & Me.Text & ".xml")
        End If
 
    End Sub
 
    Private Sub ReadFormSettingsXmlFile()
        'Read the Form Settings XML file:
 
        Dim FilePath As String
 
        If Trim(Main.ProjectPath) <> "" Then 'Read the Form Settings file in the Project Directory
            FilePath = Main.ProjectPath & "\" & "FormSettings_" & Me.Text & ".xml"
            If System.IO.File.Exists(FilePath) Then
                ReadSettings(FilePath)
            Else
                'Initialise property values:
            End If
        Else 'Read the Form Settings in the Application Directory
            FilePath = Main.ApplicationDir & "\" & "FormSettings_" & Me.Text & ".xml"
            If System.IO.File.Exists(FilePath) Then
                ReadSettings(FilePath)
 
            Else
                'Initialise property values:
            End If
        End If
 
    End Sub
 
    Private Sub ReadSettings(ByVal FilePath As String)
        Dim settingsData As System.Xml.Linq.XDocument = XDocument.Load(FilePath)
 
        'Read form position and size:
        Me.Left = settingsData.<FormSettings>.<Left>.Value
        Me.Top = settingsData.<FormSettings>.<Top>.Value
        Me.Height = settingsData.<FormSettings>.<Height>.Value
        Me.Width = settingsData.<FormSettings>.<Width>.Value
 
        'Read other settings:
 
    End Sub
 
#End Region