public virtual void Save(string file) { Type iniPropertyNameAttribute = typeof(INIPropertyNameAttribute); INIFile ini = new INIFile(); foreach(PropertyInfo sectprop in this.GetType().GetProperties()) { object[] sectattr = sectprop.GetCustomAttributes(iniPropertyNameAttribute, false); if(sectattr.Length != 0) { string sectname = ((INIPropertyNameAttribute)((sectattr)[0])).Name; INISection section = new INISection(sectname); object sectobj = sectprop.GetValue(this, null); if(section != null) { foreach(PropertyInfo prop in sectprop.PropertyType.GetProperties()) { object[] attr = prop.GetCustomAttributes(iniPropertyNameAttribute, false); if(attr.Length != 0) { string name = ((INIPropertyNameAttribute)((attr)[0])).Name; section.Add(new INIProperty(name, prop.GetValue(sectobj, null))); } } } ini.Add(section); } } ini.Save(file); }