Back to Devexpress

ASPxFileManager.SelectedFolder Property

aspnet-devexpress-dot-web-dot-aspxfilemanager-6750d937.md

latest3.6 KB
Original Source

ASPxFileManager.SelectedFolder Property

Gets the currently selected folder in the folder container.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

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

Property Value

TypeDescription
FileManagerFolder

A FileManagerFolder object that is the selected folder.

|

Remarks

Use the SelectedFolder property to get the currently selected folder in the folder container. Note that only one folder can be selected in the folder container at the same time. You can customize the appearance of the selected folder, using the folder’s FileManagerFolderStyle.SelectionActiveStyle and FileManagerFolderStyle.SelectionInactiveStyle properties, or common for files and folders, the FileManagerItemStyle.SelectionActiveStyle and FileManagerItemStyle.SelectionInactiveStyle properties.

Example

The code below demonstrates how you can show information about folder contents in a label.

csharp
public string ItemsNumberToString(int count, string item) {
        if (count != 1) item = item + "s";
        return count.ToString() + " " + item;
}
protected void ASPxFileManager1_Load(object sender, EventArgs e) {
        int FileCount = ASPxFileManager1.SelectedFolder.GetFiles().Length;
        int FolderCount = ASPxFileManager1.SelectedFolder.GetFolders().Length;
        ASPxFileManager1.JSProperties["cpLabelText"] = "The " + ASPxFileManager1.SelectedFolder.Name + " folder contains " + ItemsNumberToString(FolderCount, "folder") + " and " + ItemsNumberToString(FileCount, "file");
}
aspx
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server" ClientInstanceName="fileManager" OnLoad="ASPxFileManager1_Load">
            <Settings RootFolder="~\" ThumbnailFolder="~\Thumb\" />
            <ClientSideEvents EndCallback="function(s, e) {label.SetText(fileManager.cpLabelText);}" />
</dx:ASPxFileManager>

<dx:ASPxLabel ID="ASPxLabel1" runat="server" ClientInstanceName="label">
</dx:ASPxLabel>

See Also

SelectedFile

File Manager

ASPxFileManager Class

ASPxFileManager Members

DevExpress.Web Namespace