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

Show file count

7 Answers 218 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Ashish
Top achievements
Rank 1
Ashish asked on 20 Jun 2012, 09:08 AM
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?

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Jun 2012, 09:51 AM
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.
0
Ashish
Top achievements
Rank 1
answered on 20 Jun 2012, 02:30 PM

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?

0
Pero
Telerik team
answered on 25 Jun 2012, 07:52 AM
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.
0
Ashish
Top achievements
Rank 1
answered on 25 Jun 2012, 09:07 AM
Actually as per our requirement we don't want paging for that, we just need to show file count? is it possible without paging?
0
Rumen
Telerik team
answered on 27 Jun 2012, 01:48 PM
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.
0
Ashish
Top achievements
Rank 1
answered on 10 Jul 2012, 01:27 PM
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?
0
Ashish
Top achievements
Rank 1
answered on 16 Jul 2012, 01:16 PM
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?
Tags
FileExplorer
Asked by
Ashish
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ashish
Top achievements
Rank 1
Pero
Telerik team
Rumen
Telerik team
Share this question
or