Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Dispose() a Bitmap object after call Bitmap.save()?

Tags:

c#

bitmap

dispose

I have this:

Bitmap bmp = new Bitmap(image);
//image processing
bmp.Save(path + fileName);

and I want to know if I need to call bmp.Dispose() after this code. Thanks in advance.

like image 910
eightShirt Avatar asked Nov 30 '22 03:11

eightShirt


1 Answers

I would use using block and Path.Combine

using(var bmp = new Bitmap(image))
{
    // image processing
    bmp.Save(Path.Combine(path ,fileName));
}
like image 155
Damith Avatar answered Dec 04 '22 22:12

Damith