i am storing image name for ex img1.jpg in database (sqlserver 2005) as well as in images folder in application with the same name storing in database.
i am using gridview and use checkbox as a template column . and delete button outside of the grid to delete the checked records.
i want to delete the image from image foder when i delete a record from the gridview .
how to do that does any one that...?
Loading
Blocked AccountPosted Oct 16, 2008, 11:38 PM
Hi,
As u said u are also stoing the image name. also bind the image name in one column and make that invisible. and on deletion access the image name as u access any other value like EmpID,Name,Address,City,Emp_Image.
i hope u are getting the point.
Happy Coding!!
Mahesh ChandPosted Oct 16, 2008, 9:13 AM
jignesh kadvaniPosted Oct 16, 2008, 8:56 AM
for ex in my database i have EmpID,Name,Address,City,Emp_Image field.
now how to access that Emp_image name for particular that record..
Blocked AccountPosted Oct 16, 2008, 7:13 AM
Hi,
As u r storing the image name in the database, then it is very simple to delete from the image folder.
for that first u have to check that image exists or not. U can do this by this way.
Dim Image As FileInfo = New FileInfo(Server.MapPath("give the Url Of the Image"))
If Image.Exists Then
Image.Delete()
Else
"ErrorMessage"
End If
or
try this
File.Delete(Server.MapPath("Folder Path") + "/" + "Image Name")