The "common approach" to what you describe is IDisposable
and the Dispose()
method, most commonly exposed via using
. If that isn't working in a specific example, then there may be a coding bug in that specific example. That bug doesn't change the common approach.
Re that one example; try loading it in memory instead:
var data = File.ReadAllBytes(path);
var ms = new MemoryStream(data);
MyImage = Bitmap.FromStream(ms);