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

File explorer - get all directory files - Client side

3 Answers 430 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 28 Jul 2016, 01:33 PM

Hi I have a file browser and works great.

I am now trying to select a folder and store all the files from that directory in an array with out actually opening the folder.

 

I currently do a check to see if its a directory or file. 

 

 var selectedItems = $find("RadFileExplorer1").get_selectedItems();         

            for (var i = 0; i < selectedItems.length; i++)
            {
                var dir = selectedItems[i].isDirectory();
                if (dir == true)
                {
                }
                else if (dir == false)
                {

                }

           I am just  stuck how to get the directory file list without opening the folder. My overall goal is to be able to store a whole folder structure.

any help would be appreciated,

3 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 01 Aug 2016, 12:09 PM
Hi Paul,

I am afraid tat the the desired scenario cannot be achieved with the current implementation of RadFileExplorer. The folders in FileExplorer are loaded on demand and its client object does not know about the content of any folder which has been never opened. The only possible solution i can suggest you is to implement your own server side logic collecting the child files of the desired folders through the System.IO.Directory class API (e.g. its GetFile() method).

Regards,
Vessy
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Paul
Top achievements
Rank 1
answered on 01 Aug 2016, 01:53 PM

Ok thank you. 

I was thinking of programmatically opening each folder reading the path and checking if there are any other folders then storing the paths into an array. then looping through until it gets all the sub-folders of the selected folder.

I am just having one issue in selecting the sub folder without the function finishing. 

0
Vessy
Telerik team
answered on 04 Aug 2016, 10:22 AM
Hi Paul,

You can try a similar approach:
  • loop all folders in the current directory recursively and collect there names
  • loop through the collected paths and open them one by one
  • handle the client-side File open event and loop the content of the currently loaded folder there in order to collect its subfolders

Please note, though, that radfileExplroer updates itself via many Ajax requests and I cannot guerantee that such an approach will not break some of the controls functionality. This is why I still advise that you consider collecting the sub folders paths on the server-side like suggested in my previous reply.

Regards,
Vessy
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
FileExplorer
Asked by
Paul
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Paul
Top achievements
Rank 1
Share this question
or