Пример #1
0
        /// <summary>
        /// Auto Create Node From Path In Disk
        /// </summary>
        /// <param name="path"></param>
        /// <param name="size"> <1 is folder</param>
        /// <returns></returns>
        public static ExplorerNode GetNodeFromDiskPath(string path, long size = -1)
        {
            string[] path_split = path.Split('\\');

            ExplorerNode parent = new ExplorerNode();

            parent.NodeType.Type = CloudType.LocalDisk;
            parent.Info.Name     = path_split[0];
            for (int i = 1; i < path_split.Length; i++)
            {
                ExplorerNode node = new ExplorerNode();
                node.Info.Name = path_split[i];
                parent.AddChild(node);
                parent = node;
            }
            if (size >= 0)
            {
                parent.Info.Size = size;
            }
            else
            {
                System.IO.FileInfo info = new System.IO.FileInfo(path);
                if (info.Exists)
                {
                    parent.Info.Size = info.Length;
                }
            }
            return(parent);
        }
Пример #2
0
        public ExplorerNode MakeNodeTo(ExplorerNode RootFrom, ExplorerNode RootTo)
        {
            List <ExplorerNode> FullPathRootFrom = RootFrom.GetFullPath();
            List <ExplorerNode> NodeFullPath     = this.GetFullPath();
            CloudType           type_rootto      = RootTo.GetRoot.NodeType.Type;

            for (int i = NodeFullPath.IndexOf(RootFrom) + 1; i < NodeFullPath.Count; i++)
            {
                ExplorerNode node = new ExplorerNode();
                node.Info.Size = NodeFullPath[i].Info.Size;
                node.Info.Name = (type_rootto == CloudType.LocalDisk || type_rootto == CloudType.Dropbox) ? RemoveSpecialChar(NodeFullPath[i].Info.Name) : NodeFullPath[i].Info.Name;
                RootTo.AddChild(node);
                RootTo = node;
            }
            return(RootTo);
        }
Пример #3
0
 public ExplorerNode(NodeInfo info, ExplorerNode parent)
 {
     this.Info = info;
     parent.AddChild(this);
 }