Back to Devexpress

RichEditDocumentServer.DecryptionFailed Event

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-1b69e9c0.md

latest4.1 KB
Original Source

RichEditDocumentServer.DecryptionFailed Event

Occurs if the RichEditDocumentServer failed to open an encrypted file.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public event DecryptionFailedEventHandler DecryptionFailed
vb
Public Event DecryptionFailed As DecryptionFailedEventHandler

Event Data

The DecryptionFailed event's data class is DecryptionFailedEventArgs. The following properties provide information specific to this event:

PropertyDescription
ExceptionReturns an exception that led to the event.

Remarks

The DecryptionFailed event is raised when the RichEditDocumentServer cannot decrypt a loaded file. Check the Exception property to determine the exception that led to this event.

The event also occurs if the EncryptedFilePasswordCheckFailedEventArgs.TryAgain property is not specified or set to false.

If the event is not handled, the RichEditDocumentServer does not load an empty file.

The code sample below shows how to handle the DecryptionFailed event to show an exception message.

View Example

csharp
private static void Server_DecryptionFailed(object sender, DecryptionFailedEventArgs e)
{
    Console.WriteLine(e.Exception.Message.ToString()+" Press any key to close...");
    Console.ReadKey(true);
}
vb
Private Shared Sub Server_DecryptionFailed(ByVal sender As Object, ByVal e As DecryptionFailedEventArgs)
    Console.WriteLine(e.Exception.Message.ToString() & " Press any key to close...")
    Console.ReadKey(True)
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DecryptionFailed event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-open-and-save-encrypted-files/CS/Program.cs#L21

csharp
server.EncryptedFilePasswordCheckFailed += Server_EncryptedFilePasswordCheckFailed;
server.DecryptionFailed += Server_DecryptionFailed;

word-document-api-open-and-save-encrypted-files/VB/Program.vb#L16

vb
AddHandler server.EncryptedFilePasswordCheckFailed, AddressOf Server_EncryptedFilePasswordCheckFailed
AddHandler server.DecryptionFailed, AddressOf Server_DecryptionFailed
server.Options.Import.EncryptionPassword = "test"

See Also

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace