ZipArchive shouldn't read the Position of non-seekable Streams - by svick

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


6
0
Sign in
to vote
ID 816411 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/2/2014 8:50:59 AM
Access Restriction Public

Description

When creating a ZIP archive using ZipArchive with ZipArchiveMode.Create, the stream doesn't need to support seeking, but it does need to support reading the Position.

But according to the documentation of Stream.Position, non-seekable streams shouldn't support position, and least some don't. For example, the ASP.NET OutputStream doesn't, which means a ZIP archive can't be written directly to that Stream (seehttp://stackoverflow.com/q/16585488/41071).

Because of that, I believe this is a bug in ZipArchive that should be fixed so that ZipArchive doesn't try to get the Position of Streams whose CanSeek returns false.
Sign in to post a comment.
Posted by jnm236 on 4/11/2017 at 12:13 PM
Why on earth is this closed as won't fix? You've already fixed it in .NET Core, please fix it in .NET Framework. It's an actual bug in the framework.
Posted by jnm236 on 11/11/2016 at 6:52 AM
Can the .NET team confirm how soon this will make it into the full framework?
Posted by svick on 11/3/2016 at 1:00 PM
@jnm236 This was very recently fixed in .Net Core (see https://github.com/dotnet/corefx/pull/12682). So maybe the fix is going to be ported to .Net Framework.
Posted by jnm236 on 11/3/2016 at 12:29 PM
Changing the framework to track the position without reading the stream position seems straightforward. I understand being temporarily busy, but I don't understand why you wouldn't eventually fix this. It's such low-hanging fruit which nevertheless causes no small amount of aggravation.
Posted by Alexandru [MSFT] on 8/21/2014 at 10:05 AM
Hi svick

Thank you for your feedback. We are not going to be able to address this issue in our next release due to other priorities.

To workaround this you can implement your own stream object that will wrap the non-seekable stream. In the override for Write, you can keep count of how many bytes have been written and you can return that in the Position property.

Thanks,
Alex
.NET Framework Team
Posted by Microsoft on 2/11/2014 at 4:11 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been reproduced and has been routed to the appropriate VS development team for review. We will contact you if we require any additional information. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/ph/1117.
Posted by svick on 2/10/2014 at 9:02 AM
The “not” was meant to be “now”.
Posted by svick on 2/10/2014 at 9:02 AM
Sorry, somehow I didn't get your previous comment as an email.

I have not attached a project that shows the issue: an ASP.NET form that attempts to write a ZIP archive to ResponseStream.

The important code is in WebForm1.aspx.cs.
As it is, the code causes NotSupportedException.
If you comment out the first using and uncomment the line after that, the code starts working, thanks to the PositionWrapperStream that's in the same file.
Posted by Microsoft on 2/10/2014 at 1:44 AM
Hello again. We wanted to give you a quick reminder that to efficiently investigate and reproduce your issue, we need you to submit the additional information we requested. If we haven't heard back from you with the requested information in the next 3 days, we will go ahead and close the issue.
Posted by Microsoft on 2/6/2014 at 3:08 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/ph/1117.
Posted by Microsoft on 2/2/2014 at 9:54 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)