BufferedStream.Write(Byte[], Int32, Int32) Metodo

Definizione

Copia i byte nel flusso memorizzato nel buffer e sposta in avanti la posizione corrente all'interno del flusso memorizzato nel buffer in base al numero di byte scritti.

public:
 override void Write(cli::array <System::Byte> ^ array, int offset, int count);
public override void Write(byte[] array, int offset, int count);
override this.Write : byte[] * int * int -> unit
Public Overrides Sub Write (array As Byte(), offset As Integer, count As Integer)

Parametri

array
Byte[]

Matrice di byte da cui copiare count i byte nel flusso memorizzato nel buffer corrente.

offset
Int32

Offset nel buffer in corrispondenza del quale iniziare a copiare i byte nel flusso memorizzato nel buffer corrente.

count
Int32

Numero di byte da scrivere nel flusso memorizzato nel buffer corrente.

Eccezioni

La lunghezza di meno array è minore di .offsetcount

array è null.

offset o count è negativo.

Il flusso è chiuso o null.

Il flusso non supporta la scrittura.

I metodi sono stati chiamati dopo la chiusura del flusso.

Esempio

Questo esempio di codice fa parte di un esempio più ampio fornito per la BufferedStream classe .

// Send the data using the BufferedStream.
Console.WriteLine("Sending data using BufferedStream.");
startTime = DateTime.Now;
for(int i = 0; i < numberOfLoops; i++)
{
    bufStream.Write(dataToSend, 0, dataToSend.Length);
}
bufStream.Flush();
bufferedTime = (DateTime.Now - startTime).TotalSeconds;
Console.WriteLine("{0} bytes sent in {1} seconds.\n",
    numberOfLoops * dataToSend.Length,
    bufferedTime.ToString("F1"));
// Send the data using the BufferedStream.
printfn "Sending data using BufferedStream."
let startTime = DateTime.Now
for _ = 0 to numberOfLoops - 1 do
    bufStream.Write(dataToSend, 0, dataToSend.Length)
bufStream.Flush()
let bufferedTime = (DateTime.Now - startTime).TotalSeconds
printfn $"{numberOfLoops * dataToSend.Length} bytes sent in {bufferedTime:F1} seconds.\n"
' Send the data using the BufferedStream.
Console.WriteLine("Sending data using BufferedStream.")
startTime = DateTime.Now
For i As Integer = 1 To numberOfLoops
    bufStream.Write(dataToSend, 0, dataToSend.Length)
Next i

bufStream.Flush()
bufferedTime = DateTime.Now.Subtract(startTime).TotalSeconds
Console.WriteLine("{0} bytes sent In {1} seconds." & vbCrLf, _
    numberOfLoops * dataToSend.Length, _
    bufferedTime.ToString("F1"))

Si applica a

Vedi anche