Name initial directory

4 posts, 0 answers
  1. Juan
    Juan avatar
    20 posts
    Member since:
    Jan 2012

    Posted 31 Jan 2012 Link to this post

    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!
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 03 Feb 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Juan
    Juan avatar
    20 posts
    Member since:
    Jan 2012

    Posted 03 Feb 2012 Link to this post

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

  5. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 08 Feb 2012 Link to this post

    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 >>
Back to Top