Multiple Directories

Suppose I have the directory structure
  • Website
  •      Explorer (folder containing ASPX code)
  •      Documents
  •      Images
  •      Misc
My desire is to allow the File Explorer to be able to show files from the \Documents and \Images but exclude \Misc.

Is there a way of doing so with the utility? Either declaratively or through switching the path at runtime?

Thank you.

5 Replies

KV Karthikeyan Viswanathan Syncfusion Team August 31, 2018 11:14 AM UTC

Hi Matthew,  
  
Thanks for contacting Syncfusion support.  
  
The File Explorer component have option to hide the files from specific folders to by using access control support. You can define the access permission for specific folder by specifying access rules.   
  
In the below example, we have provided the access support for documents and images folder. Please refer to below code example.  
  
[Script]  
  
public FileAccessInfo GetRules()  
{  
    FileAccessInfo rules = new FileAccessInfo();  
    List<AccessRule> accessRules = new List<AccessRule> {  
        // Disable the permission for all files  
        new AccessRule { Path = "*.*", Role = "Document Manager", Read =Permission.Deny, Edit = Permission.Deny, Copy = Permission.Deny, Download =Permission.Deny },  
        // Enable the permission for all files inside the Documents and Images folder  
        new AccessRule { Path = "Documents/*.*", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Allow, Copy = Permission.Allow, Download =Permission.Allow },  
        new AccessRule { Path = "Images/*.*", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Allow, Copy = Permission.Allow, Download =Permission.Allow },  
        // Disable the permission for all folders  
        new AccessRule { Path = "*", Role = "Document Manager", Read =Permission.Deny, Edit = Permission.Deny, Copy = Permission.Deny, EditContents =Permission.Deny, Upload = Permission.Deny },  
        // Enable the read permission for root folder  
        new AccessRule { Path = "", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Deny, Copy = Permission.Deny, EditContents =Permission.Deny, Upload = Permission.Deny },  
        // Enable the permission for all folders inside the Documents and Images folder  
        new AccessRule { Path = "Documents", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Deny, Copy = Permission.Allow, EditContents =Permission.Allow, Upload = Permission.Allow },  
        new AccessRule { Path = "Documents/*", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Allow, Copy = Permission.Allow, EditContents =Permission.Allow, Upload = Permission.Allow },  
        new AccessRule { Path = "Images", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Deny, Copy = Permission.Allow, EditContents =Permission.Allow, Upload = Permission.Allow },  
        new AccessRule { Path = "Images/*", Role = "Document Manager", Read =Permission.Allow, Edit = Permission.Allow, Copy = Permission.Allow, EditContents =Permission.Allow, Upload = Permission.Allow },  
    };  
    rules.Rules = accessRules;  
    rules.Role = "Document Manager";  
    rules.RootPath = "~/Website/";  
    return rules;  
}  
  
  
Please refer to below help document to know more about access control support.  
  
For your reference, we have prepared a sample based on this and it can be downloaded from the link:   
  
Are you excepting this behavior? If not, please revert with more information. This would be helpful for us to provide a solution at the earliest. 
 
Regards, 
Karthikeyan V.  




MA Matthew September 20, 2018 07:14 PM UTC

This is great and solved the problem, however, is it possible to hide folders from viewing?
So in the previous example the "Misc" folder wouldn't even show up, as opposed to being visible as a folder with
a padlock.


SK Shanmugaraja K Syncfusion Team September 21, 2018 12:11 PM UTC

Hi Matthew, 
 
We have provided the class(“e-fe-lock”) for non-accessible file items in FileExplorer. So, you can use that class to find the corresponding element, then use FileExplorer events to hide it. Please check the below code snippet. 
 
 
[Script]  
 
function onHide(args) {  
      this.element.find(".e-fe-lock").parents(".e-draggable").css("display", "none");  
      this.element.find(".e-fe-lock").closest("li").css("display", "none");  
} 
 
 
 
Regards, 
Shanmugaraja K 



MA Matthew September 21, 2018 04:56 PM UTC

Fantastic. This is just what was needed. 

Thank you for the support.


SK Shanmugaraja K Syncfusion Team September 24, 2018 06:55 AM UTC

Hi Matthew, 
 
Most welcome, please let us know if you need any assistance. 
 
Regards, 
Shanmugaraja K 


Loader.
Up arrow icon