Exemple #1
0
        public static void Save(IEnumerable <Category> categories, string file)
        {
            IniWriter writer = new IniWriter();

            foreach (Category category in categories)
            {
                for (int i = 0; i < category.Count; i++)
                {
                    writer.AddValue(category[i].ToFormat(), category.ToFormat());
                }
            }
            string tempFile = Path.GetTempFileName();

            writer.Save(tempFile);
            File.Copy(tempFile, file, true);
            File.Delete(tempFile);
        }
Exemple #2
0
        /// <summary>
        /// Persisis a Template object into a file.
        /// </summary>
        /// <param name="template">The template object to save.</param>
        /// <param name="file">The file to save the data into.</param>
        public static void Save(Template template, string file)
        {
            IniWriter writer = new IniWriter();

            foreach (Category category in template)
            {
                string strCategory = CategoryToFormat(category);

                foreach (var item in category)
                {
                    writer.AddValue(CategoryItemToFormat(item), strCategory);
                }
            }
            string tempFile = Path.GetTempFileName();

            writer.Save(tempFile);
            File.Copy(tempFile, file, true);
            File.Delete(tempFile);
        }