• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Deleating contents of a directory.

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
HindyIlan
Asked:
HindyIlan
  • 2
1 Solution
 
inprasCommented:
Use SHFileOperation For that
0
 
imtiazahmadCommented:
Use CFileFind class to find the files in the directory and then use SHFileOperation to delete the files
0
 
HindyIlanAuthor Commented:
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
 
HindyIlanAuthor Commented:
Sorry my mistake (The last comment)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now