Solved

Search and kill the the file..

Posted on 2002-03-20
2
147 Views
Last Modified: 2010-05-02
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.

---FILELISTBOX---
145320_18-mrt.bck
145637_18-mrt.bck
215825_17-mrt.bck = Formatted as Time 21:58:25 Date _17- march
234226_17-mrt.bck

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..

Tanks.
0
Comment
Question by:pfjvisser
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 70 total points
ID: 6882572
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()
wend

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

CHeers
0
 

Author Comment

by:pfjvisser
ID: 6882616
Whel tanks angellll.
It worked out with a bit of recoding i had to do. There you points thanks again..
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now