none
System.IO.FileFormatException: File contains corrupted data

    Question

  • Hi!

    I use OpenXml library to count the number of pages in the pptx files uploaded by user. 90% of times it success but 10% of time it fails and give the error in the title.

    The function I call is:

    PresentationDocument.Open(file.InputStream, false), where the parameter "file" in this function is a Telerik class, Telerik.Web.UI.UploadedFile.

    The stack trace is: 

    System.IO.FileFormatException: File contains corrupted data.

       at MS.Internal.IO.Zip.ZipIOEndOfCentralDirectoryBlock.ValidateZip64TriggerValues()

       at MS.Internal.IO.Zip.ZipIOBlockManager.CreateLoadZip64Blocks()

       at MS.Internal.IO.Zip.ZipIOBlockManager.get_Zip64EndOfCentralDirectoryBlock()

       at MS.Internal.IO.Zip.ZipIOBlockManager.get_CentralDirectoryBlock()

       at MS.Internal.IO.Zip.ZipArchive.GetFiles()

       at System.IO.Packaging.ZipPackage.ContentTypeHelper..ctor(ZipArchive zipArchive, IgnoredItemHelper ignoredItemHelper)

       at System.IO.Packaging.ZipPackage..ctor(Stream s, FileMode mode, FileAccess access, Boolean streaming)

       at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)

       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(Stream stream, Boolean readWriteMode)

       at DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(Stream stream, Boolean isEditable, OpenSettings openSettings)

    Another detail to provide is that when the code run locally it success 100% of the time, but when run on the server it gives this error. 

    Any help is appreciated!

    mercredi 27 juin 2018 20:06

Toutes les réponses

  • Hello jane.m,

    Will it be related to specific document? What's the result if you open the document directly?

    What's the result if you open the document from a  System.IO.Stream instead of the Telerik.Web.UI.UploadedFile.InputStream?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    jeudi 28 juin 2018 06:10
    Modérateur