Exemplo n.º 1
0
 public DirItem FindTopLevelDir(DirectoryInfo dir)
 {
     while (dir != null)
     {
         var parent = ItemsInternal.FirstOrDefault(p => p.AbsolutePath == dir.FullName);
         if (parent != null)
         {
             return(parent as DirItem);
         }
         dir = dir.Parent;
     }
     return(null);
 }
Exemplo n.º 2
0
        public AbstractFileItem FindItem(string itemId)
        {
            var item = ItemsInternal.FirstOrDefault(c => c.Id == itemId);

            if (item != null)
            {
                return(item as AbstractFileItem);
            }
            //如果不是顶层的Item,先找到顶层的Dir.
            var path = Util.FromBase64(itemId);
            var fi   = new FileInfo(path);
            var dir  = fi.Exists ? fi.Directory : new DirectoryInfo(path);

            if (!dir.Exists)
            {
                return(null);
            }

            var topLevelDir = FindTopLevelDir(dir);
            var af1         = topLevelDir?.FindChildRecursive(dir, itemId);

            return(af1);
        }