Ejemplo n.º 1
0
        private static List <file_system_item> get_files(dir_path path)
        {
            List <file_system_item> t_item = new List <file_system_item>();

            try{
                var           sorted  = Directory.GetFiles(".").OrderBy(f => f);
                List <string> t_files = Directory.GetFiles(path.path, "*", SearchOption.TopDirectoryOnly)
                                        .Where((string x) =>
                {
                    if (null == path.filters || path.filters.Count() == 0)
                    {
                        return(true);
                    }
                    foreach (string z in  path.filters)
                    {
                        if (x.EndsWith(z))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }).OrderBy(f => f).ToList();
                foreach (string t in t_files)
                {
                    file_system_item tf = new file_system_item();
                    var fInfo           = new FileInfo(t);
                    if (fInfo.Attributes.HasFlag(FileAttributes.Hidden))
                    {
                        tf.hidden = true;
                    }
                    DateTime dt = File.GetLastWriteTime(t);

                    tf.type      = "file";
                    tf.path      = t;
                    tf.size      = get_file_size(t);
                    tf.modified  = core.relative_time(dt);
                    tf.name      = Path.GetFileName(t);
                    tf.extension = Path.GetExtension(t);
                    t_item.Add(tf);
                }
            }catch (UnauthorizedAccessException) {
            }
            return(t_item);
        }
Ejemplo n.º 2
0
 public bool get(dir_path path)
 {
     try{
         if (path.path == null)
         {
             path.path = get_home_dir();
             this.path = path.path;
         }
         if (path.path.Length >= 3 && path.path.Substring(path.path.Length - 2) == "..")
         {
             path.path = get_parent_directory(path.path.Substring(0, path.path.Length - 3));
         }
         this.path   = path.path;
         files       = get_files(path);
         directories = get_directories(path.path);
     }catch (Exception ex) {
         return(false);
     }
     return(true);
 }