User403614158 posted
I need to know how to delete an image from the file system when the user deletes an image from a photo album. Currently the sytem dletes the image location in the image table but leaves the image and it's children in the file sytem "~/pictures/".
How can I execute both on the button click?
In the Photo.VB file I have tried this but it does not work:
<System.ComponentModel.DataObjectMethodAttribute _
(System.ComponentModel.DataObjectMethodType.Delete, False)> _
Public Shared Sub DeleteImage(ByVal id As Integer)
Dim imageFileLocation As ImageUtils.ImageLocation = ImageUtils.GetLocation()
If imageFileLocation = ImageUtils.ImageLocation.Database Then
Dim qry As New Query(Tables.Images)
qry.QueryType = QueryType.Delete
qry.AddWhere(Images.Columns.Id, id)
qry.Execute()
Else
Dim qry As New Query(Tables.Image)
' **********************************
Dim fileToDelete As New FileInfo(HttpContext.Current.Request.PhysicalApplicationPath & "~\Pictures\" & "large" & imageFileLocation)
fileToDelete.Delete()
' **********************************
qry.QueryType = QueryType.Delete
qry.AddWhere(Image.Columns.Id, id)
qry.Execute()
End If
End Sub
I know this has always been a problem with CSK, but ahs anyone figured it out yet?
Thanks for any help!!
KEN