Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

del files from directory

Hi...

I have googled around for the easiest way to delete a directory, including all files below it, but there are so many to choose from.
I have tried some of them, but they dont seem to work for some reason.

The dir I want to delete only contains files, and no directories underneat.

How can I do this? Do I have to use findfirst/findnext etc?

Roald
Norway.

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hi...
    :
    : I have googled around for the easiest way to delete a directory,
    : including all files below it, but there are so many to choose from.
    : I have tried some of them, but they dont seem to work for some
    : reason.
    :
    : The dir I want to delete only contains files, and no directories
    : underneat.
    :
    : How can I do this? Do I have to use findfirst/findnext etc?
    :
    : Roald
    : Norway.
    One of the easiest ways is to use ShellExecute() and let DOS handle the deletion.
    The better way is to use FindFirst()/FindNext() to loop through the filenames and use DeleteFile() to remove them. Then you can use RemoveDir() to remove the directory itself.
Sign In or Register to comment.