<?xml version="1.0"?><configuration> <configSections> <section name="backupDirectories" type="Battistone.WindowsService.BattistoneBackup.BackupDirectorySection, BattistoneBackup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> <section name="backupSchedule" type="Battistone.WindowsService.BattistoneBackup.BackupScheduleSection, BattistoneBackup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> </configSections> <backupDirectories> <add Name="DEV_Sports_Source" SourceDirectory="C:\Dustin\Development\Visual Studio\Projects\Battistone\Sports\" DestinationDirectory="C:\Dustin\BACKUPTEST\Development\Visual Studio\Projects\Battistone\Sports\"/> <add Name="DEV_Builds" SourceDirectory="C:\Dustin\Development\Visual Studio\Projects\Battistone\Builds\" DestinationDirectory="C:\Dustin\BACKUPTEST\Development\Visual Studio\Projects\Battistone\Builds\"/> </backupDirectories> <BackupSchedule> <add BackupFrequency="Daily" BackupDays="Mon" BackupTime="23:00:00" /> </BackupSchedule> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/> </startup></configuration>
BackupDirectorySection oBackupDirectoriesConfigurationSection = BackupDirectorySection.GetConfig();
public class BackupDirectorySection : ConfigurationSection{ public static BackupDirectorySection GetConfig() { return ConfigurationManager.GetSection("backupDirectories") as BackupDirectorySection; } [ConfigurationProperty("backupDirectories")] public BackupDirectoryConfigurationCollection BackupDirectories { get { return this["backupDirectories"] as BackupDirectoryConfigurationCollection; } }}public class BackupDirectoryConfigurationCollection : ConfigurationElementCollection{ public BackupDirectoryConfiguration this[int index] { get { return base.BaseGet(index) as BackupDirectoryConfiguration; } set { if (base.BaseGet(index) != null) { base.BaseRemoveAt(index); } this.BaseAdd(index, value); } } protected override ConfigurationElement CreateNewElement() { return new BackupDirectoryConfiguration(); } protected override object GetElementKey(ConfigurationElement element) { return ((BackupDirectoryConfiguration)element).Name; }}public class BackupDirectoryConfiguration : ConfigurationElement{ [ConfigurationProperty("Name")] public string Name { get { return (string)this["Name"]; } set { this["Name"] = value; } } [ConfigurationProperty("SourceDirectory")] public string SourceDirectory { get { return (string)this["SourceDirectory"]; } set { this["SourceDirectory"] = value; } } [ConfigurationProperty("DestinationDirectory")] public string DestinationDirectory { get { return (string)this["DestinationDirectory"]; } set { this["DestinationDirectory"] = value; } }}