I'm trying to delete a folder it ends up empty following deleting files while on a form.
I've read all over about RmDir and fso.DeleteFolder, however both end up having the same problem for me. The folder remains afterwards, and ends up inaccessable until I either restart my computer or, through vba, recreate the folder and add new files.
I've troubleshooted for hours now and cannot seem to figure out why it simply won't delete the folder.
Here is the section of code that ensures there are 0 files remaining and subsequently deletes the folder. The folder remains accessible until the red line occurs, in which the folder still appears and is inaccessible. RmDir has the same effect.
Code:
Set fso = New FileSystemObject Set srcfolder = fso.GetFolder("S:\Shared\Warranty Returns\WRA Data Storage\Backups\Files\Claims\" & claimnum & " " & serialno & "\")
If srcfolder.files.count > 0 Then
For Each fsfile In srcfolder.files
If InStr(1, fsfile.Path, "Thumbs") = 0 Then Kill fsfile.Path
Next
End If
Set fso = Nothing
Set srcfolder = Nothing
Set fso = CreateObject("Scripting.FileSystemObject")
SetAttr "S:\Shared\Warranty Returns\WRA Data Storage\Backups\Files\Claims\" & claimnum & " " & serialno, vbNormal
fso.DeleteFolder "S:\Shared\Warranty Returns\WRA Data Storage\Backups\Files\Claims\" & claimnum & " " & serialno, True
Set fso = Nothing
After this is run, this is the effect...