Solved

Deleating contents of a directory.

Posted on 2000-04-21
4
180 Views
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.
Thanks,
Ilan Hindy.
0
Comment
Question by:HindyIlan
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
inpras earned 50 total points
ID: 2737185
Use SHFileOperation For that
0
 

Expert Comment

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

Author Comment

by:HindyIlan
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)

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

0
 

Author Comment

by:HindyIlan
ID: 2743485
Sorry my mistake (The last comment)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now