Back option available for File Manager

Hi Syncfusion Team,

Quick question. Is there a Back toolbar (similar to the one in Windows Explorer where we can go back on a previous folder) function for the File Manager component?

Thanks in advance!


1 Reply 1 reply marked as answer

SS Sharon Sanchez Selvaraj Syncfusion Team September 16, 2021 12:08 PM UTC

Hi Denzel, 
 
Greetings from Syncfusion support. 
 
We have checked with your reported query in FileManager. We have provided a sample, where we have given a custom Toolbar item called “Go back”. Using the ToolbarClick event, you can navigate to the previous folder which was chosen.  
 
Refer to the code snippet: 
 
FileManager Code 
  <FileManagerEvents TValue="FileManagerDirectoryContent" OnFileOpen="FileOpen" ToolbarItemClicked="toolbarClick"></FileManagerEvents> 
Events Code 
@code{ 
    SfFileManager<FileManagerDirectoryContent> filemanager; 
    public string[] Items = new string[] { "NewFolder", "Upload", "Delete", "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details", "Go back" };  
    public string currentPath = "/"; 
    public string prevPath { get; set; } 
    public void toolbarClick( ToolbarClickEventArgs<FileManagerDirectoryContent> args) {  
        if((args.Item.Text == "Go back") && prevPath != null) 
        { 
           currentPath = prevPath;  
        } 
    }  
    public void FileOpen(FileOpenEventArgs<FileManagerDirectoryContent> args) 
    { 
        prevPath = currentPath; 
        currentPath = args.FileDetails.FilterPath.Replace('\\', '/') + args.FileDetails.Name + "/"; 
    } 
} 
 
Refer to the sample: 
 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Sharon Sanchez S.

Marked as answer
Loader.
Up arrow icon