File explorer - get all directory files - Client side

4 posts, 0 answers
  1. Paul
    Paul avatar
    24 posts
    Member since:
    May 2016

    Posted 28 Jul Link to this post

    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,

  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 01 Aug Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    24 posts
    Member since:
    May 2016

    Posted 01 Aug Link to this post

    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. 

  5. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 04 Aug Link to this post

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