I'm currently working on a project application in which I'm dealing with multiple data reports. Use of multiple data reports are causing generation of multiple temporary(*.tmp) files in the application directory. So, I programmed a method to delete those temporary files from the app directory.
The code for the method goes as follows:
Public Sub deleteTMPFiles() Dim oFSO As New FileSystemObject Dim oFolder As Folder, oSF As File Set oFolder = oFSO.GetFolder(App.Path) On Error GoTo KillErr For Each oSF In oFolder.Files If Right(oSF.Name, 4) = ".tmp" Then SetAttr oSF.Path, vbNormal Kill oSF.Path ' This line's generating error End If Next Exit Sub KillErr: MsgBox Err.Description End Sub
But the method is generating an error, when it comes to delete the file. It gives a description as Permission Denied
I'm calling the method from MDIForm's unload event. I just want to delete the temporary files from the application directory. I've also tried the DeleteFile API function. It seemed as if the code ran but reflected no changes in the system.
Oh yeah.. I've also checked, the files aren't being used up by any of the processes. And I haven't even set or change any permissions these days..
Any help will be appreciated..
This post has been edited by Nash29: 17 November 2009 - 10:30 PM