FileManagerAccessRuleBase.Path Property
Gets or sets a path to which an access rule is applied.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v21.2.dll
NuGet Package: DevExpress.Web
Declaration
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | A String value specifying a path relative to the root folder, assigned via the FileManagerSettings.RootFolder property. |
Remarks
ASPxFileManager allows you to define access permissions for folders and files using a set of file/folder access rules (FileManagerSettingsPermissions.AccessRules). An access rule lists permissions (allowed or denied actions) associated with this rule. The Path property specifies a path to which the rule is applied.
Any created role can be enforced on the ASPxFileManager via its FileManagerSettingsPermissions.Role property. After that, the file manager will display the folder and files and provide access permissions to them, based on the assigned role.
Note
The FileManagerFileAccessRule.Path property value can contain the asterisk symbol (*), which means any sequence of characters.
Concept
Example
Web Forms (declaratively):
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server">
<SettingsPermissions>
<AccessRules>
<dx:FileManagerFileAccessRule Edit="Deny" Browse="Allow" Path="*.docx" />
<dx:FileManagerFolderAccessRule Role="Administrator" EditContents="Allow" Browse="Allow" Path="Documents" />
</AccessRules>
</SettingsPermissions>
</dx:ASPxFileManager>
Web Forms (in code):
ASPxFileManager fm = new ASPxFileManager();
...
FileManagerFileAccessRule fileRule = new FileManagerFileAccessRule();
fileRule.Path = "*.docx";
fileRule.Edit = Rights.Allow;
fileRule.Download = Rights.Allow;
FileManagerFolderAccessRule folderRule= new FileManagerFolderAccessRule();
folderRule.Role = "Administrator";
folderRule.EditContents = Rights.Allow;
folderRule.Browse = 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.Path = "*.docx";
fileRule.Edit = Rights.Allow;
fileRule.Download = Rights.Allow;
FileManagerFolderAccessRule folderRule= new FileManagerFolderAccessRule();
folderRule.Role = "Administrator";
folderRule.EditContents = Rights.Allow;
folderRule.Browse = Rights.Allow;
FileManager.SettingsPermissions.AccessRules.Add(fileRule);
FileManager.SettingsPermissions.AccessRules.Add(folderRule);
...
}).BindToFolder(Model).GetHtml()
Online Demo
Example
The image below demonstrates the example’s file structure in the web site solution explorer and in the file manager.
The code sample below demonstrates an example of the ASPxFileManager control’s markup.
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server" Width="700px">
<Settings RootFolder="~\Files\" ThumbnailFolder="~\Thumbnails\"
AllowedFileExtensions=".jpg, .jpeg, .gif, .rtf, .txt, .avi, .png, .mp3, .xml, .doc, .pdf" InitialFolder="Images\Employees" />
<SettingsEditing AllowCreate="True" AllowDelete="True" AllowMove="True" AllowRename="True" />
<SettingsPermissions>
<AccessRules>
<dx:FileManagerFolderAccessRule Edit="Deny" />
<dx:FileManagerFolderAccessRule Edit="Allow" Path="Documents\Reports" />
</AccessRules>
</SettingsPermissions>
</dx:ASPxFileManager>