public bool Save(string filepath) { var fileAccess = new FileWrapper(); try { string path = filepath; if (String.IsNullOrEmpty(Path.GetExtension(filepath))) { path = $"{filepath}.config"; } var fi = new FileInfo(path); if (fi.Exists) { var backupPath = $"{fi.FullName}.{DateTime.Now:yyyyMMddHHmmss}.bak"; fi.CopyTo(backupPath); } if (!String.IsNullOrEmpty(fi.DirectoryName) && !Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } string json = JsonConvert.SerializeObject(GetAll()); fileAccess.Write(fi.FullName, json); } catch { throw; } return(true); }