Exemplo n.º 1
0
 /// <summary>
 /// Iniファイルを保存
 /// </summary>
 /// <param name="fileName"></param>
 public void Save(string fileName)
 {
     using (var sw = new StreamWriter(fileName, false, this.GetEncoding()))
     {
         Section defSection = SectionList.FirstOrDefault(x => x.Name == "");
         if (defSection != null)
         {
             foreach (KeyValuePair <string, string> pair in defSection.Entries)
             {
                 sw.WriteLine("{0} = {1}", pair.Key, pair.Value);
             }
             sw.WriteLine();
         }
         foreach (Section section in SectionList.Where(x => x.Name != ""))
         {
             sw.WriteLine("[{0}]", section.Name);
             foreach (KeyValuePair <string, string> pair in section.Entries)
             {
                 sw.WriteLine("{0} = {1}", pair.Key, pair.Value);
             }
             sw.WriteLine();
         }
     }
 }