purge files with vb and access queries

B

brian

I have a VB app that searches 5 directories from the
root.

For example:

Function PurgeJobFiles()
Dim db As Database, rs As Recordset
Const OMNIchrd_PATH = "N:\OMNIchrd\"

On Error Resume Next

Set db = DBEngine.Workspaces(0).Databases(0)
Set rs = db.OpenRecordset("qryDelete_Shop_File",
DB_OPEN_DYNASET) ' Create dynaset.

rs.MoveFirst ' Move to first record.
If Err <> 0 Then
rs.Close ' Close recordset
On Error GoTo 0 ' Reset error processing
Exit Function ' Exit
End If

Do Until rs.EOF ' Loop until no matching
records.
Kill OMNIchrd_PATH & rs!JOB_NO & "*.*" '
Delete OMNI files.

rs.MoveNext ' Move to next record.
Loop ' End of loop.
MsgBox "Files have been deleted", vbOKOnly, "Deleted
Files"
rs.Close ' Close recordset
On Error GoTo 0 ' Reset error processing

End Function

This deletes every record in the root directory that
matches the query. I have been given a new task to
search directories with sub directories within
subdirectories. Is there a dynamic way of searching
through the root directory and hit all the sub
directories?

Thanks
 
L

Lance McGonigal

If you continue to use the Dir statement doesn't it show full path names for
everything in the directory and it's subs? If so, just store in a temp
table and compare to the query via a join. delete the survivors.

Just a thought

Lance
 

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

Top