Hughng Posted July 29, 2003 Posted July 29, 2003 How do I remove a directory that might contains read-only file. The Directory.delete() work fine if it only contains deletable files. But when a read-only file existed inside that directory, the function throw an exception. I am just wondering that any other command will delete the whole directory recursively. I know that dos command "Rd /s /q xxxxx" will recursively remove the whole thing, but I could not call that in VB.NET for some reason. Thank you for your help, HN Quote
*Experts* mutant Posted July 29, 2003 *Experts* Posted July 29, 2003 You have to go through every file and set the attributes so its not ReadOnly. This will do it for you: Dim f As IO.FileInfo Dim dir As New IO.DirectoryInfo("path to the directory") For Each f In dir.GetFiles f.Attributes = IO.FileAttributes.Normal Next Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.