How to prevent access for a particular folder in Blazor File Manager

Answer:

We can set the rules for FileManager component using SetRules method. Refer to the below code snippet.

public DefaultController(IHostingEnvironment hostingEnvironment)

{

this.basePath = hostingEnvironment.ContentRootPath;

this.operation = new PhysicalFileProvider();

this.operation.RootFolder(this.basePath + "\\" + this.root);

// Set Rules for FileManager component.

this.operation.SetRules(GetRules());

}


Refer to the below code snippet to prevent access from a particular folder.

public AccessDetails GetRules()

{

AccessDetails accessDetails = new AccessDetails();

List folderRule = new List {

// For Default User

new AccessRule { Path = "/Documents", Role = "Document Manager", Read = Permission.Deny, Write = Permission.Deny, Copy = Permission.Allow, WriteContents = Permission.Allow, Upload = Permission.Allow, Download = Permission.Deny },

};

accessDetails.AccessRules = folderRule;

accessDetails.Role = "Document Manager";

return accessDetails;

}


To more about Access control, refer to the below link.
https://ej2.syncfusion.com/aspnetcore/documentation/file-manager/access-control


Loader.
Up arrow icon