System.Web.UI.WebControls.FileUpload.FileBytes Property

Gets an array of the bytes in a file that is specified by using a System.Web.UI.WebControls.FileUpload control.

Syntax

[System.ComponentModel.Browsable(false)]
[System.ComponentModel.Bindable(true, System.ComponentModel.BindingDirection.OneWay)]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public byte[] FileBytes { get; }

Value

Documentation for this section has not yet been entered.

Remarks

The System.Web.UI.WebControls.FileUpload control does not automatically read the file from the client. You must explicitly provide a control or mechanism to allow the user to submit the specified file. For example, you can provide a button that the user can click to upload the file. The code that you write to save the specified file could call the FileUpload.FileBytes property, which returns the contents of the file.

Before calling the FileUpload.FileBytes property, you should use the FileUpload.HasFile property to verify that the System.Web.UI.WebControls.FileUpload control contains a file to upload. If the FileUpload.HasFile returns true, call the FileUpload.FileBytes property. If it returns false, display a message to the user indicating that the control does not contain a file. If you do not provide error-handling code to verify that a file exists, an attempt to save a nonexistent file throws an System.Web.HttpException exception.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0