In .NET, I'm running the code Directory.Delete(tempdir, true);
to permanently delete a directory and all contained files. This delete method only sends the files to recycling bin however, instead of permanently deleting them. Is there any way to force Directory.Delete
to perma-delete the directory and contained files instead of just moving to recycle bin? I couldn't find any other method overloads to do this.
EDIT: As Neil pointed out, this is not what is actually happening. Directory.Delete
is indeed permanently deleting the directory and contained files and not sending them to Recycle Bin. Sorry for any confusion
Have a look at MSDN:FileSystem.DeleteDirectory.
It has the parameter RecycleOption recycle
which uses the enum with the following options:
So calling the following would be sufficient:
My.Computer.FileSystem.DeleteDirectory(
DirectoryPath,
FileIO.UIOption.AllDialogs,
FileIO.RecycleOption.DeletePermanently);