Ajay
Ajay

Reputation: 261

Usage of Stream more than once

I am trying to upload an image file to a repository using HttpPostedFile.InputStream and resize to different thumbnail sizes using the same stream.

Suppose if I skip step 1 and perform only step 2, I am able to resize the inputstream (images) to different size. Basically it is letting me to use the inputStream only once.

How can I achieve to process both step 1 and 2 sequentially ?

I did try storing the inputStream to a variable and used separate copy for each step but no luck.

Can someone suggest/help me ?

Thank you very much

Upvotes: 3

Views: 3076

Answers (2)

Jason Williams
Jason Williams

Reputation: 57952

If you're using this stream to upload several different images to a server, you probably want to open a new stream for each file you're uploading, rather than trying to upload all of them with a single stream.

Upvotes: 0

thekip
thekip

Reputation: 3768

You did set Stream.Position to 0 before reusing it?

By storing in multiple variables you're probably only duplicating the reference to the same object in memory.

Upvotes: 5

Related Questions