I think we're missing some information here to be helpful. It looks like you have a list of streams(?) in imagenes
. You enumerate through and for each one you are creating an instance of ImagenesProducto
but that doesn't seem to be used elsewhere so we'll ignore it. You then create a new file using a stream and copy the current item (stream?) into it. By itself this code is fine so I think something else is going on here.
Look at the callstack and tell us what specifically is getting disposed too early. My gut instinct is that it is your imagen
variable which means whatever is passing you that set of items might be bad.
Step through your code and when you get to the CopyToAsync
line look at both objects in the debugger and see which one is marked as disposed.