Delete images from folder
HI, i want to delete images form folder dynamicaly, so please help me .....
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Dec 17, 2009, 9:03 PM EST
Lalit MRank #1,186 · 1.5K reputationPosted Dec 17, 2009, 9:05 PM EST
eg: Your folder name is images then
File.Delete(Server.MapPath("images") & "/" & "winter.jpg")
Lalit MRank #1,186 · 1.5K reputationPosted Dec 17, 2009, 9:13 PM EST
http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=69922
http://www.dotnetheaven.com/Uploadfile/mahesh/DeleteFileorFolder05192005090452AM/DeleteFileorFolder.aspx
Munwar Zardari20 reputationPosted Dec 17, 2009, 10:05 PM EST
Munwar Zardari20 reputationPosted Dec 17, 2009, 10:14 PM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Dec 17, 2009, 10:48 PM EST
File.Delete(filepath);
This should work.
Ex:
File.Delete("C:\\abc.jpg");
If this doesnot work for you, then that must be an error in setting the path.
Can you paste your code?
Then I can look into it?
If this answer helps, please check' do you like thsi answer' check box.
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 18, 2009, 1:48 AM EST
my email address is [email protected]
Munwar Zardari20 reputationPosted Dec 20, 2009, 10:06 PM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Dec 20, 2009, 10:49 PM EST
If it helped to you, please tick 'Do you like this answer' check box near my answer. It helps me a lot.
Lalit MRank #1,186 · 1.5K reputationPosted Mar 3, 2010, 11:45 PM EST
----------------
String imagePath = "~/ContentImages/Products/" + Image;
System.IO.FileInfo file1 = new System.IO.FileInfo(Server.MapPath(imagePath));
file1.Delete();