Forge/Utility/AutomaticBackupComponent.cs
/// <summary>
/// Trims the backup directory so that it contains the given maximum number of files. Newer
/// files are kept over older files.
/// </summary>
/// <param name="count">The number of files to keep.</param>
Trims the backup directory so that it contains the given maximum number of files. Newer
files are kept over older files.
Trims the backup directory so that it contains the given maximum number of files . Newer files are kept over older files .
private void TrimDirectory(int count) {
            string[] files = Directory.GetFiles(BackupDirectory);
            Array.Sort(files, (a, b) => {
                return File.GetLastWriteTime(a) > File.GetLastWriteTime(b) ? -1 : 1;
            });
            for (int i = count; i < files.Length; ++i) {
                File.Delete(files[i]);
            }
        }
private void TrimDirectory ( int count ) { string [ ] files = Directory . GetFiles ( BackupDirectory ) ; Array . Sort ( files , ( a , b ) => { return File . GetLastWriteTime ( a ) > File . GetLastWriteTime ( b ) ? - 1 : 1 ; } ) ; for ( int i = count ; i < files . Length ; ++ i ) { File . Delete ( files [ i ] ) ; } }
Trims the backup directory so that it contains the given maximum number of files.
Trims the backup directory so that it contains the given maximum number of files .
count
int
The number of files to keep.
The number of files to keep .