예제 #1
0
 /// <summary>
 /// Handles the RequestTreeItems event of the AssociatedObject control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param>
 void AssociatedObject_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args)
 {
     //when ParentItem is null, you need to set args.ChildList to be the root items...
     if (args.ParentItem == null)
     {
         args.ChildList = (IEnumerable)viewModel.DriveDetails;
     }
     else  //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem.
     {
         FileInfoModel item = args.ParentItem as FileInfoModel;
         args.ChildList = viewModel.GetChildFolderContent(item);
     }
 }
예제 #2
0
        /// <summary>
        /// Used to get ChildFolder Content of Particular folder
        /// </summary>
        /// <param name="fileNodeItem"></param>
        /// <returns></returns>
        public List <FileInfoModel> GetChildFolderContent(FileInfoModel fileNodeItem)
        {
            List <FileInfoModel> children = new List <FileInfoModel>();

            string folder = fileNodeItem.FullName;

            try
            {
                FileInfo fi = new FileInfo(folder);
                if ((fi.Attributes & FileAttributes.Directory) != (FileAttributes)0)
                {
                    DirectoryInfo di = new DirectoryInfo(folder);
                    // Skip Recycle Bin, System Volume Information etc.
                    if (di.Parent != null && (di.Attributes & FileAttributes.Hidden) != (FileAttributes)0 ||
                        (int)di.Attributes == -1)
                    {
                        //skip...
                    }
                    else
                    {
                        foreach (string s2 in Directory.GetDirectories(folder))
                        {
                            FileInfo fi2 = new FileInfo(s2);
                            if ((fi2.Attributes & FileAttributes.Hidden) != (FileAttributes)0)
                            {
                                continue;
                            }
                            children.Add(Infomodel(s2));
                        }
                        foreach (string s2 in Directory.GetFiles(folder))
                        {
                            FileInfo fi2 = new FileInfo(s2);
                            if ((fi2.Attributes & FileAttributes.Hidden) != (FileAttributes)0)
                            {
                                continue;
                            }
                            children.Add(Infomodel(s2));
                        }
                    }
                }
            }
            catch { }
            return(children);
        }