By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,407 Members | 2,835 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,407 IT Pros & Developers. It's quick & easy.

directory deletion with C++

P: 2
hi this ashok
I want to know about....how to delete the complete NON EMPTY directory with c++ code ?
Jun 13 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
i knew how to delete empty directory but i do not how it is....
Jun 13 '07 #2

DeMan
100+
P: 1,806
You can try doing it recursively, the general idea would be:

(note: pseudoish code, but the logic would be much the same.....)
Expand|Select|Wrap|Line Numbers
  1. DelDir(Dir);
  2.   Foreach thisElement=Dir.element(); 
  3.     if thisElement.isDir();
  4.       DelDir(thisElement);
  5.     else
  6.       thisElement.delete();
  7.     endif
  8.   end Foreach
  9. endDelDir
  10.  
(there may be a better way though......)
Jun 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.