This is a migrated thread and some comments may be shown as answers.

Custom Provider

1 Answer 59 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 12 Aug 2010, 01:49 PM
I am working with a custom provider and I have added prefixes to my folder names so that they will show up in a specific order.  I have this working except for the first level.  Have I missed something based on by code seen below.

Public Class CustomFileBrowserProviderWithFilter
    Inherits FileSystemContentProvider
    Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, ByVal selectedItemTag As String)
        MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
    End Sub

    Public Overloads Overrides Function ResolveDirectory(ByVal path As String) As DirectoryItem
        Dim originalFolder As DirectoryItem = MyBase.ResolveDirectory(path)
        Dim originalFiles As FileItem() = originalFolder.Files
        Dim filteredFiles As New List(Of FileItem)()

        ' Filter the files
        For Each originalFile As FileItem In originalFiles
            If Not Me.IsFiltered(originalFile.Name) Then
                filteredFiles.Add(originalFile)
            End If
        Next
        Dim newFolder As New DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, filteredFiles.ToArray(), originalFolder.Directories)

        Return newFolder
    End Function

    Public Overloads Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As DirectoryItem
        Dim originalFolder As DirectoryItem = MyBase.ResolveRootDirectoryAsTree(path)
        Dim originalDirectories As DirectoryItem() = originalFolder.Directories
        Dim filteredDirectories As New List(Of DirectoryItem)()

        ' Filter the folders
        For Each originalDir As DirectoryItem In originalDirectories
            If Not Me.IsFiltered(originalDir.Name) Then
                filteredDirectories.Add(originalDir)
            End If
        Next
        For N As Integer = 0 To filteredDirectories.Count - 1
            filteredDirectories(N).Name = filteredDirectories(N).Name.Replace("_", " ").Split("$")(1)
        Next
        Dim newFolder As New DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, originalFolder.Files, filteredDirectories.ToArray())

        Return newFolder
    End Function

    Private Function IsFiltered(ByVal name As String) As Boolean
        If name.ToLower().EndsWith(".vb") Or name.ToLower().EndsWith(".aspx") Then
            Return True
        End If

        ' else
        Return False
    End Function
End Class

1 Answer, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 12 Aug 2010, 01:53 PM
Nevermind apparently my computer was cacheing something because it is working now.
Tags
FileExplorer
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or