public bool SerializeObjectToFile(object obj, string path, IProgress <StorageManagerProgress> progress) { if (!VerifyObjectToSerialize(obj)) { throw new ArgumentException("serializableObject is not serializable"); } if (_settings.UseEncryption) { var encryptionManager = new EncryptionManager(); var ms = SerializeAndCompressObjectToMemoryStream(obj, progress); lock (FileLock) { return(encryptionManager.EncryptAndSaveFile(path, ms, _settings.GetPassword(), null)); } } return(SerializeAndCompressObjectToFile(obj, path, progress)); }