Attempting to delete a folder gives a "Not empty" error even when told to "DeleteAllContents"

  • Thread starter Thread starter Mugsy_in_Houston
  • Start date Start date
M

Mugsy_in_Houston

Guest
This is ticking me off. I'm trying to delete a folder that may or may not contain data. So I issue the following command:

FileIO.FileSystem.DeleteDirectory("c:\MyFolder", FileIO.DeleteDirectoryOption.DeleteAllContents)

.
But when I run my program, it appeared the command was being ignored (no error, it was simply skipped.) So I put it in a Try statement:

Try
FileIO.FileSystem.DeleteDirectory("c:\MyFolder", FileIO.DeleteDirectoryOption.DeleteAllContents)
Catch ex As Exception
MsgBox(ex.Message,, "Error")
End Try

.
And this catches an undetected error with the message "Directory not empty."

I know that. That's why I included ".DeleteAllContents". What am I missing?

TIA

Continue reading...
 
Back
Top