Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function FileExists(ByVal FileToTest As String) As Boolean
- FileExists = (Dir(FileToTest) <> "")
- End Function
- Sub DeleteFile(ByVal FileToDelete As String)
- If FileExists(FileToDelete) Then 'See above
- ' First remove readonly attribute, if set
- SetAttr FileToDelete, vbNormal
- ' Then delete the file
- Kill FileToDelete
- End If
- End Sub
- With New FileSystemObject
- If .FileExists(yourFilePath) Then
- .DeleteFile yourFilepath
- End If
- End With
- On Error Resume Next
- aFile = "c:file_to_delete.txt"
- Kill aFile
- On Error Goto 0
- return Len(Dir$(aFile)) > 0 ' Make sure it actually got deleted.
- Dim aFile As String
- aFile = "c:file_to_delete.txt"
- If Len(Dir$(aFile)) > 0 Then
- Kill aFile
- End If
- test = Dir(Filename)
- If Not test = "" Then
- Kill (Filename)
- End If
- Dim fso as New FileSystemObject, aFile as File
- if (fso.FileExists("PathToFile")) then
- aFile = fso.GetFile("PathToFile")
- aFile.Delete
- End if
Add Comment
Please, Sign In to add comment