|
-
June 16th, 2006, 12:56 AM
#1
How to delete older files automatically
Hi ,
I want to delete the files from a folder automatically when files count reaches 10 .When i save a 11th file it should delete the 1 st file(i.e . older file) so that the folder should always have only 10 files.
How to do it??
Thanks in advance.
Lata.
-
June 16th, 2006, 01:35 AM
#2
Re: How to delete older files automatically
Before creating new file every time check how many files you have in the folder if it reaches 11 then take the first one based one LastWritten time and delete then you can rename the files.
-
June 16th, 2006, 02:04 AM
#3
Re: How to delete older files automatically
well you can get all the files on the folder first to check how many existing file there is
string[] fname = System.IO.Directory.GetFiles(directoryname)
and from there your can get each of the files attribute and check which one is the oldest and delete it using "File.Delete(fileName)"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|