Why can't I delete a folder when I apparently have the requisit permissions

Felix 1 Reputation point
2020-12-07T10:55:50.253+00:00

The following is a code sequence that removes 3 files in a folder and then attempts to delete the folder. The 3 files are successfully removed but attempts the remove the folder yield a "Path/File access error" message.

`Sub testTDD()
Dim pathName As String

pathName = "E:\fiskDev_Excel\Models"  
testDelDir pathName  

End Sub

Sub testDelDir(pathName)
Dim fName As String
Dim errFlg, msg, errMsg As String

On Error GoTo EHL1  
If dirExists(pathName) Then  
    'Empty the pathName directory  
    fName = dir(pathName & "\")  
    Do While fName <> ""  
        Kill (pathName & "\" & fName)  
        fName = dir(pathName & "\")  
    Loop  
    'Remove the empty pathName directory  
    RmDir (pathName)  
End If  
Exit Sub  
  

EHL1:45579-permissions.txt
MsgBox err.description
End Sub`

The following is a screen shot of the permissions for the folder "E:\fiskDev_Excel\Models"

45752-image.png

I was logged in a Dennis Jelavic

As a side note, the application from which this problem came has been working happily for 10 years until the other day. I don't know what has happened to cause the problem.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,586 questions
Windows 10 Security
Windows 10 Security
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
2,910 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. MotoX80 33,636 Reputation points
    2020-12-07T15:04:56.997+00:00

    You likely have a running process that has an open handle to the folder. Run Process Explorer and from the Find menu item, run "Find Handle or DLL". Search for that folder name.

    https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer


  2. Ali Taqvi 1 Reputation point
    2020-12-07T22:38:33.69+00:00

    Go to advance and make yourself folder owner and then try to delete it @Felix


  3. Vicky Wang 2,731 Reputation points
    2020-12-08T09:39:42.8+00:00

    Hi,

    I am glad to hear that your issue was successfully resolved\I am pleased to know that the information is helpful to you. If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,
    Vicky

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.