/// <summary> /// Saves the given <paramref name="restoreDataObject"/> to <paramref name="path"/>. /// </summary> /// <param name="restoreDataObject">The RestoreData object that sould be saved.</param> /// <param name="path">The path, the given RestoreData object should be saved to.</param> /// <exception cref="System.ArgumentNullException"><paramref name="restoreDataObject"/> or <paramref name="path"/> is null.</exception> public static void SaveRestoreData(RestoreData restoreDataObject, string path) { if (restoreDataObject == null) { throw new ArgumentNullException("restoreDataObject"); } if (path == null) { throw new ArgumentNullException("path"); } try { using (var fileStream = new FileStream(path, FileMode.Create)) { // Yup - we don't need that object after that so just... don't save it new BinaryFormatter().Serialize(fileStream, restoreDataObject); } } // Not the finest way, but it's okay to just say nothing... // We don't want to bother the user with that. catch (SecurityException) { } }