The custom FileBrowserContentProvider implementation allows filtering
certain files from the RadFileExplorer. This example demonstrates
the implementation of a custom FileBrowserContentProvider, that filters
the showed items (files, folders). The default behavior where the files are open
in a RadWindow is changed and the files with extensions .jpg
and .gif are opened for direct download.
The CustomFileBrowserProviderWithFilter class inherits the
class and overrides its ResolveDirectory
and ResolveRootDirectoryAsTree methods. We override them and use our code,
designed to handle the certain file extensions or folders that contain certain word(s)
in their name. The example above is configured to handle items containing "Flower"
and "_sys" in their names and a "sys" file extension. The function IsFiltered()
is used to determine whether a file or folder is filtered or not. This function needs to be changed in
order to tweak the filtering.
When a file is opened (double click on it), the extension of that file is checked
inside the OnClientFileOpen event handler and in case that it is a 'jpg'
or 'gif' file the event is canceled. The file is opened for direct download
and not inside a preview window. The files are stored in a folder on the server
and the downloaded file is served by the content-streamer - Handler.ashx
file. Please note that the EnableFileOpen property needs to be set to "true"
(it is "true" by default).