Giter Club home page Giter Club logo

Comments (5)

twsouthwick avatar twsouthwick commented on September 24, 2024 1

thanks for the response - I'll take a look

from open-xml-sdk.

Numpsy avatar Numpsy commented on September 24, 2024

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.

from open-xml-sdk.

twsouthwick avatar twsouthwick commented on September 24, 2024

I believe this has been fixed in 3.0.2. Please reopen if you're still seeing this

from open-xml-sdk.

Numpsy avatar Numpsy commented on September 24, 2024

If I do something like this

static void Main(string[] args)
{
    try
    {
        using var doc = WordprocessingDocument.Open(@"S:\test\WIDE.doc", false);
    }
    catch
    {
        using var file = File.Open(@"S:\test\WIDE.doc", FileMode.Open, FileAccess.Read);
    }
}

On .NET 8.0 then the call to Open throws System.IO.FileFormatException with the message "File contains corrupted data." and then the call to File.Open fails because the file is still locked - doesn't seem right?

Debugging it, it looks like the call to Package.Open at

_package = Package.Open(_stream, mode.Value, access.Value);
throws, and then that exception escapes into the caller without disposing the FileStream created on the supplied path.

(I don't have an option to reopen the issue myself)

from open-xml-sdk.

BenjaminLopVic avatar BenjaminLopVic commented on September 24, 2024

Hello,

I am still experiencing this issue on version 3.0.2 and I am unable to reopen the issue.

Here is a sample code:

using DocumentFormat.OpenXml.Packaging;

Console.WriteLine("Hello, World!");
WordprocessingDocument wDoc = null;
try
{
    wDoc = WordprocessingDocument.Open(@"...\corruptedFile.docx", true);
}
catch (Exception ex)
{
    Console.WriteLine(ex);
}
finally
{
    wDoc?.Dispose();
}
Console.ReadKey();

With this code, the file remains locked by the console until it is shut down.

Thanks.

from open-xml-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.