Beispiel #1
0
        public myFile[] getFilebyName(String path)
        {
            myFile[] result = null;
            try
            {
                DirectoryInfo   dir     = new DirectoryInfo(path);
                FileInfo[]      inf     = dir.GetFiles();
                DirectoryInfo[] subdirs = dir.GetDirectories();
                result = new myFileSortName[inf.Length + subdirs.Length];
                //add the dirs to the result
                for (int i = 0; i < subdirs.Length; i++)
                {
                    result[i] = new myFileSortName(true, subdirs[i].Name, 0, subdirs[i].CreationTime.ToString());
                }

                //add the files to the result
                for (int i = 0; i < inf.Length; i++)
                {
                    result[i + subdirs.Length] = new myFileSortName(false, inf[i].Name, inf[i].Length, inf[i].CreationTime.ToString());
                }
                Array.Sort(result);
                return(result);
            }
            catch (DirectoryNotFoundException)
            {
                result    = new myFile[1];
                result[0] = new myFile(false, "Directory is Not Found.Please Check your Path and try again.", 0, "");
                return(result);
            }
        }
Beispiel #2
0
        public int CompareTo(object obj)
        {
            myFileSortName m = obj as myFileSortName;

            if (m == null)
            {
                throw new NotImplementedException();
            }
            return(this.getName().CompareTo(m.getName()));
        }