Deleating contents of a directory.

Posted on 2000-04-21
Medium Priority
Last Modified: 2013-11-20
Haw can I delete a contents of a directory which contains sub directories?
I tryed to use FindFirstFile, FindNextFile and DeleteFile but it deleted only the files.
Ilan Hindy.
Question by:HindyIlan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

inpras earned 200 total points
ID: 2737185
Use SHFileOperation For that

Expert Comment

ID: 2737341
Use CFileFind class to find the files in the directory and then use SHFileOperation to delete the files

Author Comment

ID: 2743075
My program is without GUI. I Tryed to write the following code and got 0 (= fail) as a return. can you tell me why?
(The directory exist and contains several files and sub directories)

      FileOpStruct.hwnd = NULL;
      FileOpStruct.pFrom = "f:\\Working Folders\\input and output";
      FileOpStruct.pTo = NULL;
      FileOpStruct.wFunc = FO_DELETE;
      FileOpStruct.fFlags =      FOF_NOCONFIRMATION |
                                          FOF_NOERRORUI         |
      int x = SHFileOperation(&FileOpStruct);


Author Comment

ID: 2743485
Sorry my mistake (The last comment)

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question