Show file count

8 posts, 0 answers
  1. Ashish
    Ashish avatar
    7 posts
    Member since:
    Jun 2012

    Posted 20 Jun 2012 Link to this post

    I am using Rad File Explorer, i have disabled file navigator. I would like to display file count for folder as below.

    Folder1(10)
    Folder2(23)
    .
    .
    .
    .
    Sample(200).

    Can you please suggest a way?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Jun 2012 Link to this post

    Hi Ashish,

    Following is the sample code that I tried based on your scenario.

    ASPX:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" Height="300px" Width="804px"  Skin="Forest">
            <Configuration SearchPatterns="*.*" UploadPaths="~/exercise/" ViewPaths="~/exercise/" DeletePaths="~/exercise/">
            </Configuration>
    </telerik:RadFileExplorer>

    C#:
    protected void Page_Load(object sender, EventArgs e)
        {
            RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomProvider).AssemblyQualifiedName;
        }
    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 ResolveRootDirectoryAsTree(string path)
            {
                DirectoryItem originalDir = base.ResolveRootDirectoryAsTree(path);
                string physicalPath = Context.Server.MapPath(path);
     
                List<DirectoryItem> childDirItems = new List<DirectoryItem>();
                foreach (DirectoryItem currentDir in originalDir.Directories)
                {
                    string physicalPathChildFile = Context.Server.MapPath(currentDir.FullPath);
                    DirectoryItem childDirItem = new DirectoryItem(currentDir.Name + "(" + Directory.GetFiles(physicalPathChildFile).Length + ")",
                                                                    currentDir.Location,
                                                                    currentDir.FullPath,
                                                                    currentDir.Tag,
                                                                    currentDir.Permissions,
                                                                    currentDir.Files,
                                                                    currentDir.Directories
                                                                      );
                    childDirItems.Add(childDirItem);
                }
                  DirectoryItem dirItem = new DirectoryItem(originalDir.Name + "(" + Directory.GetFiles(physicalPath).Length + ")",
                                                          originalDir.Location,
                                                          originalDir.FullPath,
                                                          originalDir.Tag,
                                                          originalDir.Permissions,
                                                          originalDir.Files,
                                                         childDirItems.ToArray()
                                                          );
                return dirItem;
            }
     
            public override DirectoryItem ResolveDirectory(string path)
            {
                DirectoryItem originalDir = base.ResolveDirectory(path);
                string physicalPath = Context.Server.MapPath(path);
                DirectoryItem dirItem = new DirectoryItem(originalDir.Name + "(" + Directory.GetFiles(physicalPath).Length + ")",
                                                          originalDir.Location,
                                                          originalDir.FullPath,
                                                          originalDir.Tag,
                                                          originalDir.Permissions,
                                                          originalDir.Files,
                                                          originalDir.Directories
                                                          );
                return dirItem;
            }
        }

    Hope this helps.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ashish
    Ashish avatar
    7 posts
    Member since:
    Jun 2012

    Posted 20 Jun 2012 Link to this post

    Thanks, Princy for your reply.

     

    Now my another question is, can we show total count in footer just like windows file explorer as shown in the attached file?

  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 25 Jun 2012 Link to this post

    Hello Ashish,

    When paging is enabled in the FileExplorer, the number of items in a folder is shown. Here is a link to a demo showing this: http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/initialpathandpaging/defaultcs.aspx.

    Greetings,
    Pero
    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.
  6. Ashish
    Ashish avatar
    7 posts
    Member since:
    Jun 2012

    Posted 25 Jun 2012 Link to this post

    Actually as per our requirement we don't want paging for that, we just need to show file count? is it possible without paging?
  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 27 Jun 2012 Link to this post

    Hi,

    You can disable the paging by setting AllowPaging="false" but this will hide the file count statistics.

    Best regards,
    Rumen
    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.
  8. Ashish
    Ashish avatar
    7 posts
    Member since:
    Jun 2012

    Posted 10 Jul 2012 Link to this post

    Hello Rumen,

    I think you didn't get my question. I want to disable paging, which i had did as you said. But i also want to show file count, which is not appearing after disabling paging. So any work around here?
  9. Ashish
    Ashish avatar
    7 posts
    Member since:
    Jun 2012

    Posted 16 Jul 2012 Link to this post

    Hello Princy,

    I have applied solution you have suggested. But After uploading/deleting file in directory, counter did not get update? Is there any solution around this?
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017