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

Name initial directory

3 Answers 53 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Juan
Top achievements
Rank 1
Juan asked on 31 Jan 2012, 02:29 PM
Hi

I need rename the root directory dynamically because graphically displays the name as the folder is created on the server.

example, in the server folder called "201109010750", but I need to look at FileExplorer the name "My Files"

thanks!

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 03 Feb 2012, 01:03 PM
Hi Juan,

If I understand you correctly, you need to mask the original name of the root folder to display meaningful name.

The most simple approach to achieve this will be to subclass the default content provider of RadFileExplorer and override its ResolveRootDirectoryAsTree() method and change the Name of the folder, e.g.:
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomContentProvider).AssemblyQualifiedName;
        RadFileExplorer1.Configuration.ViewPaths = new string[] { "~/root" };
    }
}
 
public class CustomContentProvider : FileSystemContentProvider
{
    public CustomContentProvider(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 orgDir = base.ResolveRootDirectoryAsTree(path);
        if (orgDir.Name.ToLower() == "root")
            orgDir.Name = "ModifiedName";
        return orgDir;
    }
}

More detailed information on how to use RadfileExplorer's content provider is available in the following help article:
Using custom FileBrowserContentProvider

For more advanced modification you will need to provide a strong mapping between real folder name and the masked one. Such approach is used in the custom content provider from the following KB article:
Use RadFileExplorer with physical and shared folder's paths


Regards,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Juan
Top achievements
Rank 1
answered on 03 Feb 2012, 02:55 PM
thanks, your solution served me so much, now, i have a quiestion; i need load the searchPatterns with some records of a database,  how can i do?.

0
Rumen
Telerik team
answered on 08 Feb 2012, 10:20 AM
Hello,

The searchPatterns property expects a string array of file extensions, e.g.

C#
RadFileExplorer1.Configuration.SearchPatterns = new string[] { "*.jpg", "*.png", "*.gif" };

VB.NET
RadFileExplorer1.Configuration.SearchPatterns = New String() {"*.jpg", "*.png", "*.gif"}

so it is up to the developer to write the code that will populate the array with values from a database.

Best regards,
Rumen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
FileExplorer
Asked by
Juan
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Juan
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or