Possible Duplicate:
How do I get a directory size (files in the directory) in C#?
I have a program which makes SQL Server backups. After every run it creates a backup file.
But the files are accumulating.
I´d like to add method which will be checking the backup directory size and if the size will be higher then threshold size, it will delete last file.
Do you know how can I do this?
Thanks a lot!
Using DirectoryInfo and a bit of Linq is an easy task
of course this is an example. You need to add a bit of error checking.
P.S. I have use the property LastWriteTime of the FileInfo class, in your case (backup files) I think that it is equivalent to CreationTime.