DeleteFile with Permission Denied
问题 I'm running into and issue that has many entries on Stack Overflow, but none of them solved my problem. I have this piece of code, which tries to delete every .txt in a folder, but I keep getting a permission denied error on the "DeleteFile" command: directory = "C:\TEST\FOLDER" Set fso = CreateObject("Scripting.FileSystemObject") Function DeleteTXTs For Each f In fso.GetFolder(directory).Files If LCase(fso.GetExtensionName(f)) = "txt" Then fso.DeleteFile("C:\TEST\FOLDER\*.txt")