Make sure you close them first.
Here's my Delete File function:
Here's the function I use to see if a file exists. It doesn't disturb the Dir queue if you are using Dir in the function that calls it:Code:Public Function DeleteFile(pstrFile As String) On Error GoTo DeleteFileErr If InStr(pstrFile, "*") = 0 And InStr(pstrFile, "?") = 0 Then SetAttr pstrFile, vbNormal Kill pstrFile DeleteFileExit: Exit Function DeleteFileErr: MsgBox Err.Description, vbInformation, "Notice" Resume DeleteFileExit End Function
Code:Public Function FileExists(pstrFile As String) As Boolean On Error GoTo FileExistsErr FileExists = True If GetAttr(pstrFile) And vbDirectory Then FileExists = False FileExistsExit: Exit Function FileExistsErr: If Err.Number = 53 Or Err.Number = 75 Then FileExists = False Else MsgBox Err.Description, vbInformation, "Notice" End If Resume FileExistsExit End Function




Reply With Quote