private static void CallEncryption(bool encryption, string filePath, byte[] passwordBytes) { try { bool kryptorExtension = filePath.EndsWith(Constants.EncryptedExtension, StringComparison.Ordinal); // Prevent Read-Only file attribute causing errors File.SetAttributes(filePath, FileAttributes.Normal); if (encryption == true && kryptorExtension == false) { Encryption.InitializeEncryption(filePath, passwordBytes); OverwriteDisabled(filePath); } else if (encryption == false && kryptorExtension == true) { Decryption.InitializeDecryption(filePath, passwordBytes); } else { DisplayMessage.FileError(filePath, encryption, kryptorExtension); } } catch (Exception ex) when(ExceptionFilters.FileAccessExceptions(ex)) { Logging.LogException(ex.ToString(), Logging.Severity.High); DisplayMessage.Error(filePath, ex.GetType().Name, "Unable to set file attributes to normal."); } }