Bug with opening corrupted Open XML documents
BenjaminLopVic opened this issue · comments
BenjaminLopVic commented
Describe the bug
Opening a corrupted document lock the file.
To Reproduce
Steps to reproduce the behavior:
- Simulate a corrupted file (simply create a txt file with content in it and change the extension to .docx)
- Try opening the file with WordProcessingDocument.Open(...)
Observed behavior
The method WordProcessingDocument.Open(...) throws an exception, stating that the file is corrupted but keeps the file locked to. This can be verified using tools like "File Locksmith."
Expected behavior
Continue throwing the exception but release the file before.
Desktop
- OS: Windows 11
- .NET Target: .NET Framework 4.8
- DocumentFormat.OpenXml Version: 3.0.1
Thanks.
Richard Webb commented
I'm seeing this as well.
Opening the file myself and passing the stream into WordprocessingDocument.Open instead of the path might be a work around.