public void Merge(string otherFilePath) { var ourRecords = ReadAllRecords(); // read all other records var otherDirary = new Diary(); otherDirary.OpenDiary(otherFilePath); if (!_header.Equals(otherDirary._header)) { throw new ApplicationException("Different headers, cannot merge"); } otherDirary._rsa = _rsa; otherDirary.IsLocked = false; var otherRecords = otherDirary.ReadAllRecords(); var merged = ourRecords.Concat(otherRecords).Distinct().OrderBy(r => r.Created).ToList(); _fileStream.Seek(_headerLength + 4, SeekOrigin.Begin); WriteRecords(merged); _fileStream.SetLength(_fileStream.Position); }