public override bool Equals(object obj) { if (!(obj is SimpleFileInfo)) { return(false); } SimpleFileInfo other = (SimpleFileInfo)obj; return(other.LastModified == LastModified && other.FileLength == FileLength && other.FileName == FileName); }
public int CompareTo(object obj) { if (!(obj is SimpleFileInfo)) { throw new ArgumentException("Incorrect type in SimpleCompare.CompareTo!"); } SimpleFileInfo other = (SimpleFileInfo)obj; return(FileName.CompareTo(other.FileName) == 0 ? FileLength.CompareTo(other.FileLength) : FileName.CompareTo(other.FileName)); }
private void B_Directory_Click(object sender, EventArgs e) { if (FBD_Directory.ShowDialog() == DialogResult.OK) { string dir = FBD_Directory.SelectedPath; fileList = SimpleFileInfo.GenerateFileList(dir); status_directorypath.Text = dir; status_dirsize.Text = fileList.Sum(file => file.FileLength).ToString() + " bytes"; status_numfiles.Text = fileList.Count() + " files"; UpdateUI(); } }
public static int SortBySize(SimpleFileInfo file1, SimpleFileInfo file2) { return(file1.FileLength.CompareTo(file2.FileLength) == 0 ? file1.FileName.CompareTo(file2.FileName) : file1.FileLength.CompareTo(file2.FileLength)); }
public static int SortByModified(SimpleFileInfo file1, SimpleFileInfo file2) { return(file1.LastModified.CompareTo(file2.LastModified) == 0 ? file1.FileName.CompareTo(file2.FileName) : file1.LastModified.CompareTo(file2.LastModified)); }
public static int SortByDirectory(SimpleFileInfo file1, SimpleFileInfo file2) { return(file1.DirName.CompareTo(file2.DirName) == 0 ? file1.FileName.CompareTo(file2.FileName) : file1.DirName.CompareTo(file2.DirName)); }