Back to Devexpress

ASPxFileManager.FileDownloading Event

aspnet-devexpress-dot-web-dot-aspxfilemanager-a9cab9d3.md

latest3.9 KB
Original Source

ASPxFileManager.FileDownloading Event

Fires on the server side before a file download starts, and allows you to cancel the action.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event FileManagerFileDownloadingEventHandler FileDownloading
vb
Public Event FileDownloading As FileManagerFileDownloadingEventHandler

Event Data

The FileDownloading event's data class is FileManagerFileDownloadingEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the action that raised the event should be canceled. Inherited from FileManagerActionEventArgsBase.
ErrorTextGets or sets a text for the explanatory message. Inherited from FileManagerActionEventArgsBase.
FileGets a file related to the event.
InputStreamGets a stream object that points to the downloaded file.
OutputStreamSet this property to change the original file content.

Remarks

Each time a file is going to be downloaded on the server side, the FileDownloading event occurs, allowing you to cancel the action. You can use the event parameter’s FileManagerFileDownloadingEventArgs.File property to identify a file that is being processed. The FileManagerFileDownloadingEventArgs.InputStream and FileManagerFileDownloadingEventArgs.OutputStream properties allow you to modify a file, before sending it to the client side.

Important

The FileManagerFileDownloadingEventArgs.InputStream and FileManagerFileDownloadingEventArgs.OutputStream properties are not in effect for cloud providers and are set to null.

The example below demonstrates how you can use the FileDownloading server-side event to add a watermark to the downloaded image files.

csharp
protected void ASPxFileManager1_FileDownloading(object source, DevExpress.Web.FileManagerFileDownloadingEventArgs e) {
    if (IsImageExtension(e.File.Extension))
        e.OutputStream = AddWatermarkToImage(e.InputStream);
}

To cancel the download operation, set the FileManagerActionEventArgsBase.Cancel property to true.

See Also

Download

FileDownloading

File Manager

File Download

ASPxFileManager Class

ASPxFileManager Members

DevExpress.Web Namespace