1
Answer

delete datagrid images in saved directory

ajay raju

ajay raju

14y
2k
1

hi!
  i am using datagrid to display images.(i write code using delete command). i delete a row in datagrid that row is deleted. but my problem is image is also deleted in saved directory.
my code like:
 String imagePath = "~/ContentImages/Products/" + Image;
            System.IO.FileInfo file1 = new System.IO.FileInfo(Server.MapPath(imagePath));
            file1.Delete();

i using this code it display one error message in run time. i.e., Access to the path is denied.
if i give image name then it deleted. but i am not giving any name it takes path of datagrid image url.
urgent. please help me. give a sample code.
Thanks.
 
Answers (1)