• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Search and kill the the file..

Hi there,
I’m in a bit of problems and I  have a filelistbox called file1.In that listbox are files called like down here.

215825_17-mrt.bck = Formatted as Time 21:58:25 Date _17- march

I need to have a coding to select the oldest file that is (215825_17-mrt.bck) ad the moment and kill it. Do you no how to do this. I need the coding fast plz. Help..

1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Hope you understand this bit of code without explanations:

dim strFile as string
dim datNow as date
dim datOldest as Date
dim datFile as Date

datNow = now()
datOldest = datNow

strFile = dir("c:\yourfiles\*.bck")
while strFile <> empty
  datFile = DateSerial ( year (datnow), Month(datnow), mid( strFile, 8,2))+ TimeSerial ( mid ( strFile, 1,2 ), mid ( strFile, 3,2), mid ( strFile, 5,2 ) )
  if datFile < datOldest then
    datOldest = datFile
  end if
  strFile = dir()

if datFile < datNow then
  strFile = "c:\yourfiles\" & Format ( datOldest, "hhnnss\_dd" & -mrt.bck"
  kill strFile
end if

pfjvisserAuthor Commented:
Whel tanks angellll.
It worked out with a bit of recoding i had to do. There you points thanks again..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now