Start New Discussion within our Software Development Community

Hi

I wonder how to count the backup files I have.

If I say like this

1: making backup OK
2: making backup OK
3: now is the question
how to count the backup files
so I can remove some of them
or kill one

Bonzo

E.g : you want to count mdb files in your app.path folder

Dim strFile As String
Dim FileCount As Integer

FileCount = 0

strFile = Dir(App.Path & "*.mdb")

Do Until strFile = ""
    FileCount = FileCount + 1
    strFile = Dir
Loop
MsgBox FileCount & " file(s)"

okej that's fine

how can I remove the file when it's count say 4
and I will remove the file #4 and no other

How you named this file?
That codes just count how many .mdb files and we don't know which file in position #4.
Actualy the Dir Function will listed and arrange the file in ascending type and order by they name.

okej that's fine

     sourcefile1 = App.Path & "\PhoneTel.mdb"
destinationfile1 = App.Path & "\backup\backup\PhoneTel.mdb" & Format(Now, "yymmdd_hhnn") & ".mdb"

where can I remove say #4 file in the backup

As i said before that we can't determine which file in position 4.
But the files always be arranged in ascending order by they name.

Say the number of files is 4 and you want to delete the file in postion 4 (the last file).
I try to put the files in listbox and accessing it by list index.

Private Sub Form_Load()

Dim strPath As String
Dim strFile As String
Dim FileCount As Integer

FileCount = 0
strPath = App.Path & "\backup\backup
strFile = Dir(strPath & "*.mdb")

Do Until strFile = ""
    FileCount = FileCount + 1
    List1.AddItem strPath & "\" & strFile
    strFile = Dir
Loop
MsgBox FileCount & " file(s)"
End Sub

Private Sub Command1_Click()
    Kill List1.List(List1.ListCount - 1)
End Sub

okej that's fine

     sourcefile1 = App.Path & "\PhoneTel.mdb"
destinationfile1 = App.Path & "\backup\backup\PhoneTel.mdb" & Format(Now, "yymmdd_hhnn") & ".mdb"

where can I remove say #4 file in the backup

This question has already been answered. Start a new discussion instead.