Problem deleting file after loading in imagelist..
-
Hi all, My application loads user selected images in Imagelist for thumbnail display in Listview...Here's the code that i use do that..
ImageList.Images.Add(imageToLoad,Image.FromFile(imageToLoad)); LstVwImage.Items.Add(imageToLoad,imageToLoad);
So far so good, When user selects any image from listview and selects Delete button, I want it to remove items from listview and imagelist and delete physical file corrosponding that path, here's the code I am using...LstVwImage.Items.RemoveAt(deleteIndex); ImageList.Images.RemoveAt(deleteIndex); FileInfo fi = new FileInfo(deleteFile); fi.Delete();
Unfortunately its not able to delete file, saying "File is being used by another process"...Its not permission error as I am able to delete any file if its not loaded in imagelist or listview... Either I'm getting crazy or stupid error!!! Pls throw some light on this!! Regards MaulikCE "Every obstacle presents an opportunity to improve our condition." -
Hi all, My application loads user selected images in Imagelist for thumbnail display in Listview...Here's the code that i use do that..
ImageList.Images.Add(imageToLoad,Image.FromFile(imageToLoad)); LstVwImage.Items.Add(imageToLoad,imageToLoad);
So far so good, When user selects any image from listview and selects Delete button, I want it to remove items from listview and imagelist and delete physical file corrosponding that path, here's the code I am using...LstVwImage.Items.RemoveAt(deleteIndex); ImageList.Images.RemoveAt(deleteIndex); FileInfo fi = new FileInfo(deleteFile); fi.Delete();
Unfortunately its not able to delete file, saying "File is being used by another process"...Its not permission error as I am able to delete any file if its not loaded in imagelist or listview... Either I'm getting crazy or stupid error!!! Pls throw some light on this!! Regards MaulikCE "Every obstacle presents an opportunity to improve our condition."