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
Post a Comment