TextControlBackgroundimage can not delete file

2 posts, 0 answers
  1. pierre-jean
    pierre-jean avatar
    53 posts
    Member since:
    Apr 2011

    Posted 23 Dec 2017 Link to this post


    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


  2. Dimitar
    Dimitar avatar
    2486 posts

    Posted 25 Dec 2017 Link to this post

    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");

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

    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.
Back to Top