Hello,
Here mentioned the default value is TryRecover:
https://reference.aspose.com/words/net/aspose.words.loading/loadoptions/recoverymode/
While here, the default value is 0 None:
https://reference.aspose.com/words/net/aspose.words.loading/documentrecoverymode/
Unless I’m greatly mistaken, the integer Enum, the default is usually zero!?!?
@australian.dev.nerds
Quick Answer
LoadOptions.RecoveryMode
defaults to DocumentRecoveryMode.TryRecover
.
The enum DocumentRecoveryMode
itself defines its members with numeric values (None = 0
, TryRecover = 1
, …). The “default value = 0” you see on the enum page refers only to the underlying integer of the enum, not to the default that Aspose.Words assigns to the LoadOptions
property.
Why the Two Pages Show Different Values
Page |
What It Describes |
Value shown |
LoadOptions.RecoveryMode |
The property that determines how a document is loaded when it is damaged. |
TryRecover |
DocumentRecoveryMode enum |
The enum definition (numeric values of each member). |
None = 0 (first enum entry) |
When you create a fresh LoadOptions
object, Aspose.Words explicitly sets the property to DocumentRecoveryMode.TryRecover
. The enum’s “default = 0” only applies when you declare a variable of type DocumentRecoveryMode
without initializing it – it will contain the first enum value (None
) because that is how .NET works.
Example Code
using Aspose.Words;
using Aspose.Words.Loading;
// Create LoadOptions with no explicit RecoveryMode set
LoadOptions options = new LoadOptions();
// The property is automatically set to TryRecover
Console.WriteLine(options.RecoveryMode); // Output: TryRecover
Console.WriteLine((int)options.RecoveryMode); // Output: 1 (numeric value)
// If you want to disable recovery:
options.RecoveryMode = DocumentRecoveryMode.None;
Notice that options.RecoveryMode
prints TryRecover
, even though the enum’s numeric value for None
is 0
.
How to Change the Behavior
Desired behavior |
Code snippet |
Use the default (TryRecover) |
var options = new LoadOptions(); |
Turn off recovery completely |
var options = new LoadOptions { RecoveryMode = DocumentRecoveryMode.None }; |
Force full recovery (when supported) |
var options = new LoadOptions { RecoveryMode = DocumentRecoveryMode.Recover }; (if the enum includes a Recover member) |
References
Need More Help?
If you have a specific scenario (e.g., loading a corrupted DOCX, customizing error handling, etc.), let us know the details and we’ll provide a targeted code sample.
1 Like
@australian.dev.nerds Thank you for pointing this out. From our point of view 0
is more expected value for None
in enum. but not to break old behavior default value for LoadOptions.RecoveryMode
is set to TryRecover
.
1 Like
Thanks, but what was the behavior of prior versions which didn’t have this DocumentRecoveryMode option? And now, if we don’t specify it?
@australian.dev.nerds In earlier versions, Aspose.Words always attempted to recover damaged files upon loading. The same behavior is preserved by default in the current version.
1 Like
Thanks for the info, so the new DocumentRecoveryMode just allows developers to disable the behavior, right? That’s great 
@australian.dev.nerds Yes, exactly. With the new options, developers can disable recovery attempts when loading documents.