Back to Devexpress

DxFileInput.MaxFileCount Property

blazor-devexpress-dot-blazor-dot-dxfileinput-76e7d88b.md

latest2.5 KB
Original Source

DxFileInput.MaxFileCount Property

Specifies the maximum number of files that users can add to the file list.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(1000)]
[Parameter]
public int MaxFileCount { get; set; }

Property Value

TypeDefaultDescription
Int321000

The maximum number of files.

|

Remarks

Once a user selects files in the Open File dialog or drags files onto a drop zone, the File Input component adds these files to the file list. In Instant upload mode ( default ), the component starts to upload a file once it appears in the file list. In OnClick upload mode, the File Input starts to upload a file once a user clicks an upload button.

Enable the AllowMultiFileUpload property to allow users to add multiple files to the file list simultaneously. The MaxFileCount property specifies the maximum file list size. When the file list reaches its size limit, users can add new files only once they remove one or more uploaded files.

Note

We do not recommend that you increase the MaxFileCount property value beyond 1000 ( default ). However, you can set this property to 0 to remove the file list’s size limit.

The following example sets the file list’s size limit to 10:

razor
<DxFileInput FilesUploading="OnFilesUploading" AllowMultiFileUpload="true" MaxFileCount="10" />

@code {
    async Task OnFilesUploading(FilesUploadingEventArgs args) {
        foreach (var file in args.Files) {
            /* The following code is intended for demonstration purposes only.
            Do not read a stream directly in memory to avoid performance and security-related issues. */
            using var stream = new System.IO.MemoryStream();
            await file.OpenReadStream(file.Size).CopyToAsync(stream);
        }
    }
}

See Also

DxFileInput Class

DxFileInput Members

DevExpress.Blazor Namespace