hi,
does anyone know how to delete a folder in c# regardless it contains a file or not or a file within it is being locked or use?
Forcely delete folder
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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
Lalit MRank #1,186 · 1.5K reputationPosted Jan 12, 2010, 6:29 PM EST
http://www.dotnetspider.com/resources/16119-create-delete-folder.aspx
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 13, 2010, 12:07 AM EST
Hi Ronald,
First you remove the readonly attribute of all the files. For that you should check all the files in the folder and also the files in the sub folders.
After removing readonly attribute, you can simply delete it from one line.Check my code. I have written a method to remove the readonly attribute and then delete the folder.
Please do not forget to tick 'Do you like this answer' checkbox if this helps you.