Button in Form to Delete all .jpg from a folder

  • Thread starter Thread starter The Boondock Saint
  • Start date Start date
T

The Boondock Saint

Is there a way you can have a button in a form set to delete files from a
folder on the computer..

Such as all the .jpg files in a certain folder on the local computer?

Any help would be awesome...
 
Here's a very simple function that will do what you asked. Note, this will
delete all jpg's in the folder you specify. Try this:

Function fDeleteFiles()

Dim strfile As String
Dim strPath As String

strPath = "YOUR FILE PATH HERE"

ChDir strPath
strfile = Dir("*.jpg")

Do While Len(strfile) > 0
'delete the file
Kill strPath & "/" & strfile
strfile = Dir
Loop

End Function
 
Sure, use kill. For example this would delete all jpg files in C:\Temp:
Kill "C:\Temp\*.jpg"
 
Ive found a way of doing it using a .bat file ... thank goodness for Dos :)

but still interested in if there is a better way
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top