File Explorer taking too long to load due to too many folders

1 Answer 119 Views
FileExplorer
Trevor
Top achievements
Rank 1
Trevor asked on 16 Aug 2022, 09:30 AM | edited on 16 Aug 2022, 01:44 PM

I am using a custom provider for file explorer control that gets folders from a database. The folders number in the 40 000s. I am facing the problem of now the page taking too long to load because the file explorer is trying to get the subfolders  for the 40000 something folders in the root directory in the the ResolveRootDirectoryAsTree Method. The page now takes hours to load.


 Public Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As DirectoryItem
        Dim directory As DirectoryItem = dataServer.GetDirectoryItem(path, True)

        If directory Is Nothing Then
            Return Nothing
        End If
        directory.Permissions = GetPermissions(path)

        If directory.Directories IsNot Nothing Then
            For Each dir As DirectoryItem In directory.Directories
                dir.Permissions = GetPermissions(path)
            Next
        End If

        Return directory
    End Function


 


Public Function GetDirectoryItem(ByVal path As String, ByVal includeSubfolders As Boolean) As DirectoryItem
        Dim item As DataRow = Me.GetItemRowFromPath(path)

        Return If(item IsNot Nothing, Me.CreateDirectoryItem(item, includeSubfolders), Nothing)
    End Function

    Private Function CreateDirectoryItem(ByVal item As DataRow, ByVal includeSubfolders As Boolean) As DirectoryItem
        'correct permissions should be applied from the content provider
        Dim directory As New DirectoryItem(item("Description").ToString(), Me.GetLoaction(item), Me.GetFullPath(item), [String].Empty, PathPermissions.Read, Nothing,
         Nothing)
        directory.Attributes.Add("CategoryID", item("CategoryID"))

        If includeSubfolders Then
            Dim subDirItems As DataRow() = GetChildDirectories(item)
            Dim subDirs As New List(Of DirectoryItem)()

            For Each subDir As DataRow In subDirItems
                subDirs.Add(CreateDirectoryItem(subDir, False))
            Next

            directory.Directories = subDirs.ToArray()
        Else
            directory.Directories = (New List(Of DirectoryItem)).ToArray()
        End If

        Return directory
    End Function

 

Is there a way to stop the initial load of the subfolders of the folders in the root folder and load them on demand? Or what can i do to make it more efficient in loading the too many folders?

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 18 Aug 2022, 02:03 PM

Hi Trevor,

RadFileExplorer loads its content on demand, thus it is expected for the second loading of a folder to be faster. When the page is loaded for the first time only the root folders and their first child folders are loaded (if the InitialPath property is not set). When you click on a child folder then the control initiates asynchronous requests and loads the sub-folders of the clicked folder. If you have more files in a folder, then the control will load slowly and this is normal behavior.

In order to optimize the loading you could try the following approaches and see whether they are applicable to your scenario:
  • Set the ExplorerMode property of the RadFileExplorer control to FileTree.
    This will improve the loading performance the data-binding in this mode is done on the server, not on the client. When the ExplorerMode.Default is set the client-side DataBinding feature of the grid is used, which is slower than the server-side binding.

    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" ExplorerMode="FileTree">
        <Configuration ViewPaths="~/root" />
    </telerik:RadFileExplorer>
  • If you want to keep the FileList of FileExplroer, though, make sure that you use it in its ExplorerMode.Default mode, but not the Thumbnails one. The thumbnails mode uses the original image to create the thumbnails dynamically, thus its performance depends on the size and the count of the loaded images

    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" ExplorerMode="Default">
        <Configuration ViewPaths="~/root" />
    </telerik:RadFileExplorer>
  • Set AllowPaging="true" property in order to turn on paging in the grid and PageSize="10". In this case, only 10 items will be shown per page in the grid. Note, that even in this case, the Grid will need to resolve all items in first loading of the folder in order to calculate the count of the pages that will be needed.

    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" PageSize="10" AllowPaging="true">
        <Configuration ViewPaths="~/Images/big" />
    </telerik:RadFileExplorer>
  • Another option is to remove the TreeView from the visible controls and keep only the Grid for listing the files and folders as this will decrease the calls of the ResolveRootDirectoryAsTree() method in times:

    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server"  DisplayUpFolderItem="true"
        PageSize="10" AllowPaging="true" ExplorerMode="Default"
        VisibleControls="AddressBox,ContextMenus,Grid,Toolbar">
        <Configuration ViewPaths="~/Images" />
    </telerik:RadFileExplorer>
  • If you choose the option above (to remove the TreeView), you can optimize the performance even more by enabling VirtualScrolling for the RadGrid component in RadFileExplorer like explained in the following KB: Setup virtual scrolling in the RadGrid embedded in RadFileExplorer
  • You can set the <compilation debug="false"/> in the web.config file of your application as it will speed up FileExplorer quite a bit. When debug is set to true, the ASP.NET AJAX extensions client script adds a lot of overhead (e.g. function parameters checking), which in this case slows down client databinding.

I hope these suggestions will be helpful for you in optimizing the loading of the needed data. 

 

Regards,
Rumen
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
FileExplorer
Asked by
Trevor
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or