Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete files in folder based on modified date.

Status
Not open for further replies.

rkckjk

IS-IT--Management
Apr 27, 2001
34
US
Let's say I have the following folder:
C:\Archive\Data\Logs\

and within this folder are many files in this format:
Cycle Run of Tuesday, February 01, 2005.html
Cycle Run of Wednesday, February 02, 2005.html
.
.
.
Cycle Run of Monday, February 28, 2005.html


The folder gets larger every day when a new file is created. What I want to do is setup an application that would delete all the previous month's files. I would setup an executable to run off a PC as a 'Scheduled Task' on the 28th of every month to delete the previous month's files. So, example on the 28th of March it would delete all the files that were created in February. I guess you would somehow use the 'Modified Date'?

 
take a look at the System.IO namespace, specificly the file object and the directory object.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top