Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone, I have problem with vb.net.
When I try to delete a folder - "Access to the path denied"

here code:
VB
Dim path As String = "C:\Users\" + SystemInformation.UserName + "\AppData\Local\Test"

        If Directory.Exists(path) Then

            Directory.Delete(path, True)
        Else
            Console.WriteLine(path & " not exists")
        End If


Please help!
Posted
Comments
Dave Kreskowiak 19-Sep-15 20:39pm    
Either the person running the code doesn't have permissions to delete the folder or a file in the folder is being held open by some process.

You need to run your program with administrator privileges. You do not have permissions to delete the folder.
 
Share this answer
 
Comments
Maciej Los 20-Sep-15 9:33am    
5ed!
Abhinav S 20-Sep-15 13:03pm    
Thanks!
The error message is clear enough. You have no permissions[^] to delete specific folder. See: Access to the specified device, path or file is denied.[^]

BTW: i'd strongly recommend to use DirectoryInfo class[^].
 
Share this answer
 
Comments
Abhinav S 20-Sep-15 13:03pm    
5.
Maciej Los 20-Sep-15 13:27pm    
Thank you, Abhinav.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900