Guest User

Untitled

a guest
Mar 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Function FileExists(ByVal FileToTest As String) As Boolean
  2. FileExists = (Dir(FileToTest) <> "")
  3. End Function
  4.  
  5. Sub DeleteFile(ByVal FileToDelete As String)
  6. If FileExists(FileToDelete) Then 'See above
  7. ' First remove readonly attribute, if set
  8. SetAttr FileToDelete, vbNormal
  9. ' Then delete the file
  10. Kill FileToDelete
  11. End If
  12. End Sub
  13.  
  14. With New FileSystemObject
  15. If .FileExists(yourFilePath) Then
  16. .DeleteFile yourFilepath
  17. End If
  18. End With
  19.  
  20. On Error Resume Next
  21. aFile = "c:file_to_delete.txt"
  22. Kill aFile
  23. On Error Goto 0
  24. return Len(Dir$(aFile)) > 0 ' Make sure it actually got deleted.
  25.  
  26. Dim aFile As String
  27. aFile = "c:file_to_delete.txt"
  28. If Len(Dir$(aFile)) > 0 Then
  29. Kill aFile
  30. End If
  31.  
  32. test = Dir(Filename)
  33. If Not test = "" Then
  34. Kill (Filename)
  35. End If
  36.  
  37. Dim fso as New FileSystemObject, aFile as File
  38.  
  39. if (fso.FileExists("PathToFile")) then
  40. aFile = fso.GetFile("PathToFile")
  41. aFile.Delete
  42. End if
Add Comment
Please, Sign In to add comment