Delete Files that are a Specified Number of Days Old.

Category:
Files and Directories
Type:
Snippets
Difficulty:
Intermediate
Author:
Intelligent Solutions Inc.

Version Compatibility: Visual Basic 6

More information:
Use this function to delete all files X number of days old, relative to today's date (or relative to another date specified in an optional parameter). You can use a file name or a FileSpec (e.g., "C:\temp\*.txt"). Make sure you know what you are doing, since the function permanently deletes files.

VB 6 is required because the Split function is used. If you want to do this in VB5, see this article from the MS knowledge base, which shows you how to implement Split in VB5.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: