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?