Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is this .NET 4.0?</p> <p>If so <a href="http://msdn.microsoft.com/en-us/library/dd782932.aspx" rel="nofollow noreferrer">Stream.CopyTo</a> is probably your best bet.</p> <p>If not, and to give credit where credit is due, see the answer in <a href="https://stackoverflow.com/questions/230128/best-way-to-copy-between-two-stream-instances-c">this SO thread.</a> If you're not .NET 4.0 make sure to read the comments in that thread as there are some alternative solutions (<a href="https://stackoverflow.com/questions/1540658/net-asynchronous-stream-read-write">Async stream reading/writing</a>) that may be worth investigating if performance is at an absolute premium which may be your case.</p> <p>EDIT:</p> <p>Based off the update, are you trying to copy the file to another remote destination? (Just guessing based on GetRequestStream() [<a href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.getrequeststream.aspx" rel="nofollow noreferrer">GetRequestStream()</a>]. The time is going to be the actual transfer of the file content to the destination. So in this case when you do fs.CopyTo(strm) it has to move those bytes from the source stream to the remote server. That's where the time is coming from. You're literally doing a file upload of a huge file. CopyTo will block your processing until it completes.</p> <p>I'd recommend looking at spinning this kind of processing off to another task or at the least look at the asynchronous option I listed. You can't really avoid this taking a large period of time. You're constrained by file size and available upload bandwidth.</p> <p>I verified that when working <em>locally</em> CopyTo is sub-second. I tested with a half gig file and a quick Stopwatch class returned a processing time of 800 millisecondss.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload