c# - In the GDI + error general form -
i have directory, in directory image background.jpg
in work load image in background
imagebrush imgbrush = new imagebrush(); imgbrush.imagesource = new bitmapimage(new uri("images/background.jpg", urikind.relative)); border.background = imgbrush;
after pattern during, need change image. shake server, try write in images/background.jpg , exception
"in gdi + error general form" - translate russian.
get image server , save computer
httpwebrequest lohttp = (httpwebrequest)webrequest.create(request); lohttp.method = "get"; lohttp.protocolversion = httpversion.version11; httpwebresponse lowebresponse = (httpwebresponse)lohttp.getresponse();
streamreader loresponsestream = new streamreader(lowebresponse.getresponsestream()); system.drawing.image webimage = system.drawing.image.fromstream(lowebresponse.getresponsestream()); try { webimage.save("images/background.jpg");//this exception imagebrush imgbrush = new imagebrush(); imgbrush.imagesource = new bitmapimage(new uri("images/background.jpg", urikind.relative)); parent.getsetborder.background = imgbrush; } catch { }
what should do?
yes, code work once. after called save(), you've got lock on file. saving again bomb. must call dispose() after calling save() bitmap disposed , file lock released.
not using using statement or calling dispose() on disposable class object away in .net. on bitmaps.
Comments
Post a Comment