BEGroup.Utility.IniFile.SaveAs C# (CSharp) Method

SaveAs() public method

Saves this INI file to the specified path.
public SaveAs ( string path, bool overwrite = true ) : void
path string Path of the INI file
overwrite bool whether to overwrite if the target file exists
return void
        public void SaveAs(string path, bool overwrite = true)
        {
            if (File.Exists(path))
            {
                if (overwrite) File.Delete(path); else throw new IOException("Target file exists and cannot be overwritten.");
            }

            using (StreamWriter sw = new StreamWriter(path))
            {
                foreach (string section in _content.Keys)
                {
                    sw.WriteLine(FORMAT_SECTION, section);
                    foreach (string key in _content[section].Keys)
                    {
                        sw.WriteLine(FORMAT_KEY_VALUE, key, _content[section][key]);
                    }
                    sw.WriteLine();
                }
                sw.Flush();
            }
        }