-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[API Proposal]: Stream.CopyTo{Async} with count #102177
Comments
Tagging subscribers to this area: @dotnet/area-system-io |
Why would the argument be nullable if we have overloads that don't accept it for those who don't have the value?
I am afraid that introducing these two overloads in the proposed form would cause a compiler error because the compiler would not know whether provided number is source.CopyTo(dst, 100); // is 100 bufferSize or count?
public virtual void CopyTo(Stream! destination, int bufferSize);
public virtual Task! CopyToAsync(Stream! destination, int bufferSize, CancellationToken cancellationToken); Nevertheless I see the problem you are trying to solve and I agree we should provide a solution for it. |
A specific use case for this need was to copy a huge file while reporting IProgress back to the UI thread. |
Background and motivation
I need to copy a part of a stream to another stream.
API Proposal
This functionality is already a part of dotnet org, being used by aspnet.core repo, but is currently internal:
https://github.com/dotnet/aspnetcore/blob/d731e85ab8961368a6c41453dcfa2ebfa251f01d/src/Http/Shared/StreamCopyOperationInternal.cs
It is also slightly different from the current Stream.CopyToAsync
API Usage
Alternative Designs
No response
Risks
None. The advantage is that aspnet.core would not need to have its own implementation.
BTW, the existence of such API seemed so obvious to me, that I just code searched GitHub for
CopyToAsync
in dotnet org and was not disappointed.The text was updated successfully, but these errors were encountered: