VB6 Delete File & Directories
can anyone code this better?
the function is to locate and delete files in a directory
Code:
' remove hidden and readonly attributes
SetAttr file_name, vbNormal
' Check for dir
If GetAttr(file_name) And vbDirectory Then
' if true delete it
DeleteDirectory file_name
End If
' set lbl to display current file
Me.lblFile.Caption = file_name
Me.lblFile.Refresh
'check to see if the file is locked
If FileIsLocked(file_name) Then
' if true unlock it
UnLockFile (file_name)
' take ownership
ChangeOwnerOfFile (file_name)
'Delete it.
Kill file_name
Else
' just delete it
Kill file_name
End If