i was looking at the FileExplorer and wondered if it was possible to Filter Files that can be seen.
I found the following code, which i found at http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/hide-files-and-folders.aspx :
:
i can see how it works, and was wondering if its possible to not have to hardcode what the file 'EndsWith' in the IsFiltered Function.
My files will all be stored in the one Folder (no other Folders will be accessible to the user), and the Files in the Folder should be Filtered depending on who is viewing it.
so, for example, if you are logged in as 'London', you should only see Files that End With '_London.csv'.
equally, if you are logged in as 'Manchester', you should only see Files that End With '_Manchester.csv'.
There are many different Logins, so i would prefer not to have to have a different Folder for each Login.
I found the following code, which i found at http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/hide-files-and-folders.aspx :
:
Public
Class
CustomProvider
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
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
Not
name.ToLower().EndsWith(
".sys"
.ToLower.ToString() +
".csv"
)
Then
Return
True
End
If
' else
Return
False
End
Function
End
Class
i can see how it works, and was wondering if its possible to not have to hardcode what the file 'EndsWith' in the IsFiltered Function.
My files will all be stored in the one Folder (no other Folders will be accessible to the user), and the Files in the Folder should be Filtered depending on who is viewing it.
so, for example, if you are logged in as 'London', you should only see Files that End With '_London.csv'.
equally, if you are logged in as 'Manchester', you should only see Files that End With '_Manchester.csv'.
There are many different Logins, so i would prefer not to have to have a different Folder for each Login.