Deleting image files after deleting a picture
Hi,
One of the things that I noticed is that images are not deleted after deleting a picture from an album. I'm only on Chapter 14, but I verified that this is in the final code by running it. I wanted to add code so that a picture would be deleted after successfully deleting a picture record from the Pictures table. I figured that this would be done in the code behind for ManagePhotoAlbum. So I created an EntityDataSource1_Deleting event. My plan was to cast e.Entity to a Picture, use the ImageUrl to get the name, and use File.Delete. But when I look at ((Picture)e.Entity).ImageUrl, the value is null. The only value available is the Id column. I was kind of hoping that there might be a way to use LINQ to get the ImageUrl for the Id that I have. But I couldn't figure out a way to do that.
Any suggestions?
Thanks.
|