deleting images from gridview as well as folder also

Posted by Madhuri123 under Regular Expressions on 6/22/2011 | Points: 10 | Views : 4923 | Status : [Member] | Replies : 3
hi,
I am display a images in gridview.when deleting the images,the images is deleted in db but not in folder. how i can delete a image from database as well as image


<asp:Image ID ="ProductImage" runat ="server" ImageUrl ='<%#Eval("Image1","Browse/Image/{0}")%>' Height="50" Width="50" AlternateText="Image Unavailable"/>




Responses

Posted by: Lakn2 on: 6/22/2011 [Member] Starter | Points: 25

Up
0
Down
hi,

use the following code

using System.IO; //namespace for file class


use this code after delete from database

File.Delete(Server.MapPath("images") & "/" & "imagename.jpg")


hope this will help you




Thanks&Regards
LakshmiNarayana Nalluri.

Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vforvijay on: 6/22/2011 [Member] Starter | Points: 25

Up
0
Down
hi..Try this link...in this article they mention code for to delete image in folder..i hope this one helpful to u..
http://vbdotnetaddict.blogspot.com/2011/06/how-to-store-imageurl-in-database-and.html


Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 6/22/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
try this
using System.IO;

File.Delete(Server.MapPath("images") & "/" & "image1.jpg")


Thanks
Karthik
www.f5Debug.net

Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response