} // /// <summary> /// Deletes all but one file from every group of matches. /// Returns the total size of deleted items. /// </summary> /// <param name="matches"></param> public long DeleteMatches( bool moveToTrash=false, MatchOrdering deleteOrder = MatchOrdering.None ) { long totalSize = 0; this.SortMatches( deleteOrder ); foreach ( FileMatchGroup match in this ) { totalSize += match.DuplicatesSize; string[] files = match.RemoveMatches(); int len = files.Length; /// don't delete the first file from each group. for ( int i = 0; i < len; i++ ) { if ( moveToTrash ) { RecycleBinDeleter.Delete( files[i] ); } else { File.Delete( files[i] ); } } // for-loop. } // for-loop. return totalSize; } //
/// <summary> /// Sorts the matches in every matching group according to a given order. /// </summary> /// <param name="order"></param> public void SortMatches( MatchOrdering order ) { if ( order == MatchOrdering.None ) { return; } foreach ( FileMatchGroup match in this ) { match.SortMatches( order ); } } //
public void SortMatches( MatchOrdering order ) { if ( order == MatchOrdering.ReverseLexigraphic ) { this.filePaths.Sort( /// later lexigraphic names (e.g. 'z') come first. ( a, b ) => { return string.Compare( b, a, StringComparison.CurrentCulture ); } ); } else { this.filePaths.Sort( ( a, b ) => { return string.Compare( a, b, StringComparison.CurrentCulture ); } ); } }