Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    DxFileInput.MaxFileSize Property

    Specifies the maximum file size in bytes.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    #Declaration

    C#
    [Parameter]
    public int MaxFileSize { get; set; }

    #Property Value

    Type Description
    Int32

    The maximum file size in bytes.

    #Remarks

    Once a user adds a file to the file list, the File Input component validates the file size. If validation fails, the File Input cannot upload this file and displays an error message.

    Specify MaxFileSize and MinFileSize properties to set maximum and minimum size limits of files that the File Input component can upload. The following example allows users to upload files from 1 to 4 KB in size:

    Razor
    <DxFileInput FilesUploading="OnFilesUploading" MinFileSize="1024" MaxFileSize="4096" />
    
    @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