Afficher en anglais

Partage via


FileStream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) Méthode

Définition

Débute une opération de lecture asynchrone. Utilisez ReadAsync(Byte[], Int32, Int32, CancellationToken) à la place.

C#
public override IAsyncResult BeginRead (byte[] array, int offset, int numBytes, AsyncCallback? callback, object? state);
C#
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback? callback, object? state);
C#
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
C#
public override IAsyncResult BeginRead (byte[] array, int offset, int numBytes, AsyncCallback callback, object state);
C#
public override IAsyncResult BeginRead (byte[] array, int offset, int numBytes, AsyncCallback callback, object? state);
C#
public override IAsyncResult BeginRead (byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject);

Paramètres

arraybuffer
Byte[]

Mémoire tampon dans laquelle lire les données.

offset
Int32

Dans array, décalage d'octet auquel commencer la lecture.

numBytescount
Int32

Nombre maximal d'octets à lire.

callbackuserCallback
AsyncCallback

Méthode à appeler quand l'opération de lecture asynchrone est terminée.

statestateObject
Object

Objet fourni par l'utilisateur qui distingue cette requête de lecture asynchrone des autres requêtes.

Retours

Objet référence la lecture asynchrone.

Exceptions

La longueur du tableau moins offset est inférieure à numBytes.

array a la valeur null.

offset ou numBytes est un nombre négatif.

Une lecture asynchrone a été tentée au-delà de la fin du fichier.

S’applique à

Produit Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1