-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.IO.Packaging.ZipPackage returns "Stream too long" exception with big files #42855
Comments
Thanks for reporting, @qmatteoq . Can you please share the callstacks as well? |
Hello @carlossanlop , sorry for the noob question, but which is the preferred way to share the call stack? The one included in the Visual Studio window doesn't seem to contain many information:
|
@qmatteoq please disable the "just my code" feature in the debugger options, it should show more of the callstack. Or I believe you can click (maybe right click) on |
Thanks @danmosemsft ! I have enabled "Show external code" in the Call Stack window, let me know if these information are enough:
|
I didn't try it but this looks like #35815.
|
https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.zipfileextensions.createentryfromfile?view=netcore-3.1#System_IO_Compression_ZipFileExtensions_CreateEntryFromFile_System_IO_Compression_ZipArchive_System_String_System_String_System_IO_Compression_CompressionLevel_ warns about this "When ZipArchiveMode.Update is present, the size limit of an entry is limited to Int32.MaxValue. This limit is because update mode uses a MemoryStream internally to allow the seeking required when updating an archive, and MemoryStream has a maximum equal to the size of an int...." but there's no mention in If the above helps I wonder whether you'd be interested in offering a PR to /~https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.IO.Packaging/Package.xml |
Thanks @danmosemsft ! Your suggestion did the trick. I'll be more than happy to open a PR on the documentation. Thanks a lot for the help! |
Great. If this seems common we could presumably catch and rethrow with a more helpful message. Or maybe it’s simply fixable @carlossanlop may know whether it is? |
It is very too old (4 years!) issue PowerShell/Microsoft.PowerShell.Archive#19 I hope this will be improved in 6.0. Why not use file mappings for large archives? |
@qmatteoq if you get a chance to open a PR in dotnet-api-docs to update this file, that would be great. @danmosemsft since this issue has been reported many times, maybe it would be good to invest in trying to throw a more helpful message, and throw it earlier. I opened this issue to consider the improvement: #43542
I'll close this since it's been answered. |
Description
I'm using the following code, based on the System.IO.Packaging.ZipPackage API, to generate zip files in a WPF application:
This code works fine in the version of the application based on .NET Framework 4.6, regardless of the size of the file to compress. On .NET Core, instead, the operation fails with an IOException and the message "Stream too long" if the file is too big.
Configuration
Regression?
Yes, the same code works fine in .NET Framework 4.6.
Other information
You can find a simple repro project here: https://1drv.ms/u/s!AhGLm1VCMcxP7t4yZ5iWm2NwKGf0Dg?e=XajuD2.
This project creates a 2 GB text file in a temporary folder and then tries to zip it using the above code. The project comes with two .csproj files: one for the .NET Framework 4.6 version, which works fine; one for the .NET Core 3.1 version, which generates the IOException.
The text was updated successfully, but these errors were encountered: