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

Exclude Directorys

2 Answers 52 Views
Editor
This is a migrated thread and some comments may be shown as answers.
sidcom
Top achievements
Rank 1
sidcom asked on 30 Jan 2009, 11:47 AM
Hi There

I have written a HTML Editor for one of our clients. It employs the the File Explorer so that the user can select the html file and load it into rad editor.

The user has full access to the root of the directory. I have used the search patterens to restrict access to certain files. I would like to also make it so that certain directorys are not show in the file explorer.

e.g Users shouldnt be able to see the bin folder and app_data folder.

What is the best way to restrict access to these directorys whilst still allowing access to the root folder.

Thanks in advance.

 

2 Answers, 1 is accepted

Sort by
0
sidcom
Top achievements
Rank 1
answered on 02 Feb 2009, 09:07 AM
Any news on this?
0
Lini
Telerik team
answered on 02 Feb 2009, 05:18 PM
Hi,

The file explorer control uses a content provider model to interact with the files and folders. Unfortunately, you can only specify which folders to include in the ViewPaths so there is no straightforward way to exclude certain folders. However, you can easily extend the default content provider and add this functionality. Here is an example, which removes the Bin and App_Data folders from the file explorer:

protected void Page_Load(object sender, EventArgs e) 
    FileBrowser1.Configuration.ContentProviderTypeName = typeof(myProvider).AssemblyQualifiedName; 
    FileBrowser1.Configuration.ViewPaths = new string[] { "~/" }; 
 
public class myProvider : FileSystemContentProvider 
    public myProvider(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 ResolveRootDirectoryAsTree(string path) 
    { 
        DirectoryItem rootFolder = base.ResolveRootDirectoryAsTree(path); 
        List<DirectoryItem> folders = new List<DirectoryItem>(rootFolder.Directories); 
        foreach (DirectoryItem folder in rootFolder.Directories) 
        { 
            if (folder.Name == "Bin" || folder.Name == "App_Data"
            { 
                folders.Remove(folder); 
            } 
        } 
        rootFolder = new DirectoryItem(rootFolder.Name, rootFolder.Location, rootFolder.FullPath, rootFolder.Tag, rootFolder.Permissions, rootFolder.Files, folders.ToArray()); 
        return rootFolder; 
    } 

In this example I override the function which is called to get the folder contents and check if it contains subfolders with specific names.

Kind regards,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
sidcom
Top achievements
Rank 1
Answers by
sidcom
Top achievements
Rank 1
Lini
Telerik team
Share this question
or