public class CustomProvider : FileSystemContentProvider
{
public CustomProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
: base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
{ }
public override DirectoryItem ResolveDirectory(string path)
{
DirectoryItem originalFolder = base.ResolveDirectory(path);
FileItem[] originalFiles = originalFolder.Files;
List<FileItem> filteredFiles = new List<FileItem>();
// Filter the files
foreach (FileItem originalFile in originalFiles)
{
if (!this.IsFiltered(originalFile.Name))
{
filteredFiles.Add(originalFile);
}
}
DirectoryItem newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, filteredFiles.ToArray(), originalFolder.Directories);
return newFolder;
}
public override DirectoryItem ResolveRootDirectoryAsTree(string path)
{
DirectoryItem originalFolder = base.ResolveRootDirectoryAsTree(path);
DirectoryItem[] originalDirectories = originalFolder.Directories;
List<DirectoryItem> filteredDirectories = new List<DirectoryItem>();
// Filter the folders
foreach (DirectoryItem originalDir in originalDirectories)
{
if (!this.IsFiltered(originalDir.Name))
{
filteredDirectories.Add(originalDir);
}
}
DirectoryItem newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, originalFolder.Files, filteredDirectories.ToArray());
return newFolder;
}
private bool IsFiltered(string name)
{
return name == Web.SETTINGS_FILENAME;
}