Back to Devexpress

FileManagerFile.Folder Property

aspnet-devexpress-dot-web-dot-filemanagerfile.md

latest3.6 KB
Original Source

FileManagerFile.Folder Property

Gets the parent folder to which the current file belongs.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public FileManagerFolder Folder { get; }
vb
Public ReadOnly Property Folder As FileManagerFolder

Property Value

TypeDescription
FileManagerFolder

A FileManagerFolder object representing the file’s immediate parent.

|

Remarks

Use the Folder property to identify the parent folder which owns the current file.

Example

The code below allows end-users to upload only mp3 files to the “Music mp3” folder.

csharp
protected void ASPxFileManager1_FileUploading(object source, DevExpress.Web.FileManagerFileUploadEventArgs e) {
      if (e.File.Folder.FullName == "Files\\Music mp3")
            if (e.File.Extension != ".mp3") {
                e.Cancel = true;
                e.ErrorText = "You can only upload mp3 files to this folder";
            }
}
aspx
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server" OnFileUploading="ASPxFileManager1_FileUploading">
            <Settings RootFolder="~/Content/FileManager/Files" ThumbnailFolder="~\Thumb" />
</dx:ASPxFileManager>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Folder property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-file-manager-list-custom-file-system-provider/CS/WebApplication2/FileStreamProvider.cs#L115

csharp
protected FileSystemData FindFileItem(FileManagerFile file) {
    FileSystemData folderItem = FindFolderItem(file.Folder);
    List<FileSystemData> files = DataSource.Where(x => !x.IsFolder).ToList();

asp-net-web-forms-file-manager-list-custom-file-system-provider/VB/WebApplication2/FileStreamProvider.vb#L118

vb
Protected Function FindFileItem(ByVal file As DevExpress.Web.FileManagerFile) As FileSystemData
    Dim folderItem As WebApplication2.FileSystemData = Me.FindFolderItem(file.Folder)
    Dim files As System.Collections.Generic.List(Of WebApplication2.FileSystemData) = Me.DataSource.Where(Function(x) Not x.IsFolder).ToList()

See Also

File Manager

FileManagerFile Class

FileManagerFile Members

DevExpress.Web Namespace