internal async Task SaveConfig()
 {
     FolderPathMap[SelectedArea]   = folderStoreID + "\\" + folderEntryID;
     FolderNameMap[SelectedArea]   = selFolderName;
     AddressToMap[SelectedArea]    = AddressTo;
     AddressCcMap[SelectedArea]    = AddressCc;
     ForwardedTxtMap[SelectedArea] = ForwardedTxt;
     using (var sw = new StreamWriter(ConfigurationManager.AppSettings["settingsPath"], false))
     {
         foreach (string area in Areas)
         {
             if (FolderNameMap.ContainsKey(area))
             {
                 await sw.WriteLineAsync($"{area}\t{CsvFolderName}\t{FolderNameMap[area].Replace("\t", " ")}");
             }
             if (FolderPathMap.ContainsKey(area))
             {
                 await sw.WriteLineAsync($"{area}\t{CsvFolderPath}\t{FolderPathMap[area].Replace("\t", " ")}");
             }
             if (AddressToMap.ContainsKey(area))
             {
                 await sw.WriteLineAsync($"{area}\t{CsvAddressTo}\t{AddressToMap[area].Replace("\t", " ")}");
             }
             if (AddressCcMap.ContainsKey(area))
             {
                 if (!String.IsNullOrWhiteSpace(AddressCcMap[area]))
                 {
                     await sw.WriteLineAsync($"{area}\t{CsvAddressCc}\t{AddressCcMap[area].Replace("\t", " ")}");
                 }
             }
             if (ForwardedTxtMap.ContainsKey(area))
             {
                 if (!String.IsNullOrWhiteSpace(ForwardedTxtMap[area]))
                 {
                     foreach (string line in ForwardedTxtMap[area].Replace("\t", " ").Split('\n'))
                     {
                         await sw.WriteLineAsync($"{area}\t{CsvForwardedTxt}\t{line}");
                     }
                 }
             }
         }
     }
 }
        internal async Task ReadConfig()
        {
            string settingsPath = ConfigurationManager.AppSettings["settingsPath"];

            if (File.Exists(settingsPath))
            {
                using (var sr = new StreamReader(settingsPath))
                {
                    var linesMap = new Dictionary <string, List <string> >();
                    foreach (string area in Areas)
                    {
                        linesMap[area] = new List <string>();
                    }
                    while (!sr.EndOfStream)
                    {
                        string line = await sr.ReadLineAsync();

                        if (String.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        string[] fields = line.Split('\t');
                        if (fields.Length != 3 || !Areas.Contains(fields[0]))
                        {
                            continue;
                        }
                        switch (fields[1])
                        {
                        case CsvFolderPath:
                            FolderPathMap[fields[0]] = fields[2];
                            continue;

                        case CsvFolderName:
                            FolderNameMap[fields[0]] = fields[2];
                            continue;

                        case CsvAddressTo:
                            AddressToMap[fields[0]] = fields[2];
                            continue;

                        case CsvAddressCc:
                            AddressCcMap[fields[0]] = fields[2];
                            continue;

                        case CsvForwardedTxt:
                            linesMap[fields[0]].Add(fields[2]);
                            continue;

                        default:
                            continue;
                        }
                    }
                    foreach (string area in Areas)
                    {
                        ForwardedTxtMap[area] = String.Join("\n", linesMap[area]);
                    }
                }
                var folderPath = FolderPathMap.ContainsKey(SelectedArea) ? FolderPathMap[SelectedArea] : "";
                if (SelectedArea == AuthFwd && folderPath != null)
                {
                    var folderKeys = folderPath.Split('\\');
                    if (folderKeys.Length == 2)
                    {
                        folderStoreID = folderKeys[0];
                        folderEntryID = folderKeys[1];
                    }
                }
                else
                {
                    folderStoreID = "";
                    folderEntryID = "";
                }
                SelFolderName = FolderNameMap.ContainsKey(SelectedArea) ? FolderNameMap[SelectedArea] : "";
                AddressTo     = AddressToMap.ContainsKey(SelectedArea) ? AddressToMap[SelectedArea] : "";
                AddressCc     = AddressCcMap.ContainsKey(SelectedArea) ? AddressCcMap[SelectedArea] : "";
                ForwardedTxt  = ForwardedTxtMap.ContainsKey(SelectedArea) ? ForwardedTxtMap[SelectedArea] : "";
            }
        }