Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > FileExplorer > Name initial directory

Not answered Name initial directory

Feed from this thread
  • Juan avatar

    Posted on Jan 31, 2012 (permalink)

    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!

    Reply

  • Dobromir Dobromir admin's avatar

    Posted on Feb 3, 2012 (permalink)

    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

    Reply

  • Juan avatar

    Posted on Feb 3, 2012 (permalink)

    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?.

    Reply

  • Rumen Rumen admin's avatar

    Posted on Feb 8, 2012 (permalink)

    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 >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > FileExplorer > Name initial directory
Related resources for "Name initial directory"

ASP.NET FileExplorer Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]