Esempio n. 1
0
        public int sortBySize(LSFileInfo lsfi1, LSFileInfo lsfi2)
        {
            int      rc = 0;
            FileInfo fi1, fi2;

            if (lsfi1.isDirectory && lsfi2.isDirectory)
            {
                return(string.Compare(lsfi1.info.Name, lsfi2.info.Name));
            }
            else
            {
                if (!lsfi1.isDirectory && !lsfi2.isDirectory)
                {
                    // both files.
                    fi1 = lsfi1.info as FileInfo;
                    fi2 = lsfi2.info as FileInfo;
                    if ((rc = string.Compare(fi1.DirectoryName, fi2.DirectoryName)) == 0)
                    {
                        rc = (int)(fi1.Length - fi2.Length);
                    }
                }
                else
                {
                    // One file, one directory.
                    return(lsfi1.isDirectory ? -1 : 1);
                }
            }
            return(rc);
        }
Esempio n. 2
0
 public int sortByName(LSFileInfo lsfi1, LSFileInfo lsfi2)
 {
     if (lsfi1.isDirectory && lsfi2.isDirectory)
     {
         return(string.Compare(lsfi1.info.Name, lsfi2.info.Name));
     }
     if (!lsfi1.isDirectory && !lsfi2.isDirectory)
     {
         return(string.Compare(lsfi1.info.Name, lsfi2.info.Name));
     }
     return(lsfi1.isDirectory ? -1 : 1);
 }
Esempio n. 3
0
        public int sortByTime(LSFileInfo lsfi1, LSFileInfo lsfi2)
        {
            int      rc = 0;
            FileInfo fi1, fi2;

            if (lsfi1.isDirectory && lsfi2.isDirectory)
            {
                return(string.Compare(lsfi1.info.Name, lsfi2.info.Name));
            }
            else if (!lsfi1.isDirectory && !lsfi2.isDirectory)
            {
                fi1 = lsfi1.info as FileInfo;
                fi2 = lsfi2.info as FileInfo;
#if true
                rc = fi1.LastWriteTime.CompareTo(fi2.LastWriteTime);
#else
                lrc = (fi1.LastWriteTime.Ticks - fi2.LastWriteTime.Ticks);
                if (lrc == 0)
                {
                    rc = 0;
                }
                else if (lrc > 0)
                {
                    rc = -1;
                }
                else
                {
                    rc = 1;
                }
#endif
            }
            else
            {
                return(lsfi1.isDirectory ? -1 : 1);
            }
            return(rc);
        }