Here are three examples of how you might use FileNameSet in one of your programs. They have been extracted from working programs, and simplified a little.
| This subroutine is used in a program that processes purchase orders contained in .ORD files. When a purchase order is processed, the extent is changed to .PCD. This subroutine is called at the end of processing to remove the processed files so that they will not be processed again. It does this by using a FileNameSet object, fns, to first create the list of .PCD files and then delete all of them. |
|
Sub DeleteOldFiles() 'clean out processed files Dim fns As FileNameSet 'declare object Set fns = New FileNameSet 'initialize object Call fns.CreateSet(PCDataDirectory, "PO*.PCD") 'create list of files Call fns.DeleteSet 'delete all of them Set fns = Nothing 'clean up memory End Sub |
| This subroutine is part of a program that periodically checks for the existance of certain file types and performs actions based on what is found in the files. While there is no error in reprocessing the files, this subroutine is called at the beginning of processing to delete any files that have already been processed to keep the load down. A FileNameSet object, fns, is used to perform these actions by first creating a list of files matching the mask, "FOF$*.$$$", and then deleting all whose date/time stamp is more than one day old. |
|
Sub
DeleteExpiredFiles() 'clean out files older than todays |
| As part of a program that collects timecard inputs, this subroutine uses a FileNameSet object, fileset, to look for two types of files on a network server, delete any files more than 30 days old, and then to fetch the full name of each remaining file and send it off to a processing subroutine.. |
|
Sub Process() 'Process upload and change files Dim fileset as FileNameSet 'declare object Set fileset = New FileNameSet 'initialize object Call fileset.CreateSet("C:\", "PY*.TXT") 'add upload files to list Call fileset.CreateSet("C:\","PY*.CHG") 'add change files to list Call fileset.DeleteOld(30) 'delete files older than 30 days For i = 1 to fileset.Count 'loop through list of files Call ProcessFile(fileset.GetName(i)) Then 'process a file next i Set fileset = Nothing 'clean up memory End Sub |