public static bool SaveToFile(ObservableCollection <User> users, string filePath) { if (users == null) { return(false); } try { using (MemoryStream stream = new MemoryStream()) { BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(stream, users); DESHelper.EncryptToFile(stream.ToArray(), filePath); return(true); } } catch { return(false); } }