|
using System;
using System.Collections;
namespace DuplicateFinder.Comparers
{
public class FileListComparer : IComparer
{
private string m_FirstFolder = string.Empty;
public int Compare(object x, object y)
{
if ((x == null) && (y == null))
{
return 0;
}
else
{
long xLength = ((System.IO.FileInfo)x).Length;
long yLength = ((System.IO.FileInfo)y).Length;
int retval = ((System.IO.FileInfo)x).Length.CompareTo(((System.IO.FileInfo)y).Length);
return retval;
}
}
public FileListComparer(string firstFolder)
{
m_FirstFolder = firstFolder;
}
public int FileNameComparer(string[] fileInfoA, string[] fileInfoB)
{
if (fileInfoA[4] + "\\" + fileInfoA[0] == fileInfoB[4] + "\\" + fileInfoB[0])
return 0;
string fiA = fileInfoA[3] + fileInfoA[4].ToLower();
string fiB = fileInfoB[3] + fileInfoB[4].ToLower();
if (fileInfoA[3] != fileInfoB[3])
return fileInfoA[3].CompareTo(fileInfoB[3]);
if (fileInfoA[4].ToLower().Contains(m_FirstFolder))
return -1;
if (fileInfoB[4].ToLower().Contains(m_FirstFolder))
return 1;
return fiA[3].CompareTo(fiB[3]);
}
public static int FileSizeComparer(System.IO.FileInfo fileA, System.IO.FileInfo fileB)
{
return fileA.Length.CompareTo(fileB.Length);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
in his studies, erratum discovered c/c++.he appreciated it.
when he met oracle products, in his job, he fell in love.
he uses c# .net & ms sql.
he created a "f.r.i.e.n.d.s" like soap movie, melting all of the above.
went back in the university.
after he took courses of artificial vision & imagery, he finished his studies with a successful license plate recognition project.