UnsolvedCoding
Technical User
Hey guys -
I wrote a sub that creates a folder to hold files and then when its done I want to delete the folder so the computer doesn't get bogged down with pointless information.
Problem - I keep getting permission denied when I try to delete the file and I think its because its on the C drive. The sub folders get deleted and recreated as needed during the process but the main folder is giving me trouble.
Does anyone know how to delete a folder from the C drive?
Here's the current code -
Sub Delete_Folder()
'Delete whole folder without removing the files first
Dim FSO As Object
Dim MyPath As String
Set FSO = CreateObject("scripting.filesystemobject")
MyPath = "C:\Pending_Temp"
If FSO.FolderExists(MyPath) = False Then
MsgBox MyPath & " doesn't exist"
Exit Sub
End If
FSO.deletefolder MyPath
Set FSO = Nothing
MyPath = Empty
End Sub
I wrote a sub that creates a folder to hold files and then when its done I want to delete the folder so the computer doesn't get bogged down with pointless information.
Problem - I keep getting permission denied when I try to delete the file and I think its because its on the C drive. The sub folders get deleted and recreated as needed during the process but the main folder is giving me trouble.
Does anyone know how to delete a folder from the C drive?
Here's the current code -
Sub Delete_Folder()
'Delete whole folder without removing the files first
Dim FSO As Object
Dim MyPath As String
Set FSO = CreateObject("scripting.filesystemobject")
MyPath = "C:\Pending_Temp"
If FSO.FolderExists(MyPath) = False Then
MsgBox MyPath & " doesn't exist"
Exit Sub
End If
FSO.deletefolder MyPath
Set FSO = Nothing
MyPath = Empty
End Sub