We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Prevent from going back too far

Is it possible to prevent them from going farther back than the specified path folder?  It always seems to let them go as far back as the last folder specified in the root of Controllers/FileManagerController.cs.  For example, if the root folder is z:\\folder1\\folder2\\folder3, and the path specified in initialization is \\folder4, it lets them go back to folder3.  Is there a way to stop them at folder 4?

5 Replies

KR Keerthana Rajendran Syncfusion Team November 18, 2019 12:30 PM UTC

Hi William,  
Greetings from Syncfusion support. 
We have checked your reported query that don’t go back to the folder3. If you don’t want to go back to the folder3, then you can specify the root path as z:\\folder1\\folder2\\folder3\\folder4 in your controller side. It will load the folder4 as the root path and displays only the subfolder of the folder4. In that case, there is no need to specify the path property. Path property is not mandatory for loading the file manager component. It is used for navigating the folder path during initial loading.  
If you want to display the folder3 and its subfolder. In that case, you need to specify the root path as z:\\folder1\\folder2\\folder3 and declare the path property as folder4. It helps you to access the folder3 and its subfolder. This is the default behavior of file manager component.  
Please let us know, if you have any concerns. 

WI William November 18, 2019 05:18 PM UTC

Thanks for the reply, Keerthana.  The problem is, I am using two instances of the file manager and folder3 is the deepest common folder.  Is there any way I can set the root to folder 4, then go back a folder to folder3 in the path setting for one of them?

KR Keerthana Rajendran Syncfusion Team November 19, 2019 12:24 PM UTC

Hi William, 
Good day to you, 
Yes, it is possible to change root folder based on file manager instances. To achieve your requirement, first you have to pass custom attribute for any one of file manager instance using beforeSend() event and then change the root of the file manager based on passed custom value in controller side. 
For your reference, we have prepared a sample. In that sample, we have passed custom attribute using beforeSend() event for file manager component. 
Refer the below code snippet for custom attribute. 
let fileObject: FileManager = new FileManager({ 
  ajaxSettings: { 
    url: hostUrl + "api/FileManager/FileOperations", 
    getImageUrl: hostUrl + "api/FileManager/GetImage", 
    uploadUrl: hostUrl + "api/FileManager/Upload", 
    downloadUrl: hostUrl + "api/FileManager/Download" 
  view: "Details", 
  beforeSend: function(args) { 
    var data = JSON.parse(args.ajaxSettings.data); 
    // Add custom parameter column 
    data["column"] = true; 
    // Add custom parameter in ajax settings 
    args.ajaxSettings.data = JSON.stringify(data); 
Based on the custom parameter, you have set the root path of file manager and declare the custom variable in controller side. Refer the below code snippet for controller. 
public object FileOperations([FromBody] FileManagerDirectoryContent1 args) 
                root = "wwwroot\\Files"; 
                root = "wwwroot\\Files\\Documents"; 
            this.operation.RootFolder(this.basePath + "\\" + this.root); 
public class FileManagerDirectoryContent1 
        public string TargetPath { get; set; } 
        public string ParentId { get; set; } 
        public string FilterId { get; set; } 
        public string FilterPath { get; set; } 
        public bool column { get; set; } 
Refer the local service and sample link below. 
Note: After running the local service, refer the localhost URL in file manager component. 
Please let us know, if you have any concerns. 

WI William November 19, 2019 08:01 PM UTC

Thank you, Keerthana,

This is exactly what I needed and fixed all my problems.

KR Keerthana Rajendran Syncfusion Team November 20, 2019 04:52 AM UTC

Hi William,  
Most welcome. We are happy to hear that the issue has been resolved in your end. Please get back to us if you need any further assistance.  

Live Chat Icon For mobile
Up arrow icon