c# - Export file using image saved to memory stream -


i wanting save image file has been stored in memory stream.

i have saved asp.net chart memory stream.

stream1 = new memorystream(); chart_location_3.saveimage(stream1, chartimageformat.png); 

and using following code export jpg. triggers save prompt , creates file image not open ("this not valid bitmap file, or format not supported")

system.web.httpresponse response = system.web.httpcontext.current.response;  system.drawing.image img;  img = system.drawing.image.fromstream(stream1); response.clearcontent(); response.clear(); response.contenttype = "image/jpg"; response.addheader("content-disposition", "attachment; filename= exported.jpg;"); response.write(img); response.flush(); response.end(); 

changed response write to:

response.binarywrite(stream1.toarray()); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -