Question Deleting a Directory Error

stulish

Well-known member
Joined
Jun 6, 2013
Messages
61
Programming Experience
3-5
Hi guys,

I have been having a problem deleting a directory, the code i use is:

VB.NET:
My.Computer.FileSystem.DeleteDirectory("W:\New One", FileIO.DeleteDirectoryOption.DeleteAllContents, FileIO.RecycleOption.DeletePermanently)

and the intermediate window shows:

A first chance exception of type 'System.ComponentModel.InvalidEnumArgumentException' occurred in Microsoft.VisualBasic.dll

i then tried:

VB.NET:
 IO.Directory.Delete("W:\New One", True)

and it worked YAY, next i wanted to delete a directory inside a directory so i used:

VB.NET:
 IO.Directory.Delete("W:\New Folder\New One", True)

But this now throws up:

A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll

and its the same drive with the same permissions and Visual Studio is running in Administrator also??

Any Ideas anyone ????
 
My.Computer.FileSystem.DeleteDirectory("W:\New One", FileIO.DeleteDirectoryOption.DeleteAllContents, FileIO.RecycleOption.DeletePermanently)
There's no DeleteDirectory method that would allow arguments like that.
But this now throws up: UnauthorizedAccessException
That can also happen if there's a file somewhere in there with ReadOnly attribute set.
 
JohnH,

Thanks i had just found a file in the folder with the RO attrib set as you posted , as soon as i un-ticked it it works fine, i think i need a sleep now :)
 
Back
Top