FileManagerFileAccessRule Class
Specifies an access rule for a file within a file manager.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Remarks
ASPxFileManager allows you to define access permissions for folders and files using a set of folder/file access rules. Access rules for files are denoted by FileManagerFileAccessRule objects. The set of rules are contained within file manager’s FileManagerSettingsPermissions.AccessRules collection.
The FileManagerFileAccessRule members allow you to specify a path pattern (PathPattern) and role (FileManagerAccessRuleBase.Role) to which a rule is applied, and lists permissions (allowed or denied actions) associated with this rule. You can specify permissions to download (FileManagerFileAccessRule.Download), and edit (FileManagerAccessRuleBase.Edit) a file. The rule priority is determined by its index (CollectionItem.Index) within an access rules collection.
Concept
Example
Web Forms (in markup):
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server">
<SettingsPermissions>
<AccessRules>
<dx:FileManagerFileAccessRule Edit="Deny" PathPattern="*.docx" />
<dx:FileManagerFolderAccessRule Role="Administrator" EditContents="Allow" Path="Documents" />
</AccessRules>
</SettingsPermissions>
</dx:ASPxFileManager>
Web Forms (in code):
ASPxFileManager fm = new ASPxFileManager();
...
FileManagerFileAccessRule fileRule = new FileManagerFileAccessRule();
fileRule.PathPattern = "*.docx";
fileRule.Edit = Rights.Deny;
FileManagerFolderAccessRule folderRule= new FileManagerFolderAccessRule();
folderRule.Role = "Administrator";
folderRule.EditContents = Rights.Allow;
FileManager.SettingsPermissions.AccessRules.Add(fileRule);
FileManager.SettingsPermissions.AccessRules.Add(folderRule);
...
MVC:
@Html.DevExpress().FileManager( settings => {
settings.Name = "fileManager";
FileManagerFileAccessRule fileRule = new FileManagerFileAccessRule();
fileRule.PathPattern = "*.docx";
fileRule.Edit = Rights.Deny;
FileManagerFolderAccessRule folderRule= new FileManagerFolderAccessRule();
folderRule.Role = "Administrator";
folderRule.EditContents = Rights.Allow;
FileManager.SettingsPermissions.AccessRules.Add(fileRule);
FileManager.SettingsPermissions.AccessRules.Add(folderRule);
...
}).BindToFolder(Model).GetHtml()