This is a migrated thread and some comments may be shown as answers.

TextControlBackgroundimage can not delete file

1 Answer 46 Views
TextBoxControl
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 23 Dec 2017, 03:49 PM

Hello

I have a dynamically loaded textboxcontrol to which I attach an image from a file as background image.

At some point I need to remove the textboxcontrol from the RadPanel into which it has been added and I need to delete the image file used as background image

The File.delete(imagefilename) generates an error telling the it cannot delete the file because it is in use by another process.

I have tried to set the backgroundimage to nothing before the file delete but it does not help

Does anyone know how can I release the file ?

Thanks in advance

Pierre-Jean

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 25 Dec 2017, 07:53 AM
Hi Pierre,

Make sure that the stream used for file opening is disposed of. Dispose of the image object as well:
var image = Image.FromFile(@"C:\img\delete.png");
image.Dispose();

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TextBoxControl
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Dimitar
Telerik team
Share this question
or