TextControlBackgroundimage can not delete file

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

    Posted 23 Dec 2017 Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    2023 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");
    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.
Back to Top