StreamWriter.Write Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Scrive dati nel flusso.
Overload
Write(String, Object, Object, Object) |
Scrive una stringa formattata nel flusso, usando la stessa semantica del metodo Format(String, Object, Object, Object). |
Write(String, Object, Object) |
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object, Object) metodo . |
Write(Char[], Int32, Int32) |
Scrive una sottomatrice di caratteri nel flusso. |
Write(String, Object[]) |
Scrive una stringa formattata nel flusso, usando la stessa semantica del metodo Format(String, Object[]). |
Write(Char[]) |
Scrive una matrice di caratteri nel flusso. |
Write(String) |
Scrive una stringa nel flusso. |
Write(ReadOnlySpan<Char>) |
Scrive un intervallo di caratteri nel flusso. |
Write(Char) |
Scrive un carattere nel flusso. |
Write(String, Object) |
Scrive una stringa formattata nel flusso, usando la stessa semantica del metodo Format(String, Object). |
Write(String, Object, Object, Object)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso, usando la stessa semantica del metodo Format(String, Object, Object, Object).
public:
override void Write(System::String ^ format, System::Object ^ arg0, System::Object ^ arg1, System::Object ^ arg2);
public override void Write (string format, object? arg0, object? arg1, object? arg2);
override this.Write : string * obj * obj * obj -> unit
Public Overrides Sub Write (format As String, arg0 As Object, arg1 As Object, arg2 As Object)
Parametri
- format
- String
Stringa in formato composito.
- arg0
- Object
Primo oggetto da formattare e scrivere.
- arg1
- Object
Secondo oggetto da formattare e scrivere.
- arg2
- Object
Terzo oggetto da formattare e scrivere.
Commenti
Per Write(String, Object, Object, Object) una descrizione delle funzionalità di formattazione composita offerte, vedere .
Si applica a
Write(String, Object, Object)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object, Object) metodo .
public:
override void Write(System::String ^ format, System::Object ^ arg0, System::Object ^ arg1);
public override void Write (string format, object? arg0, object? arg1);
override this.Write : string * obj * obj -> unit
Public Overrides Sub Write (format As String, arg0 As Object, arg1 As Object)
Parametri
- format
- String
Stringa in formato composito.
- arg0
- Object
Primo oggetto da formattare e scrivere.
- arg1
- Object
Secondo oggetto da formattare e scrivere.
Commenti
Per Write(String, Object, Object) una descrizione delle funzionalità di formattazione composita offerte, vedere .
Si applica a
Write(Char[], Int32, Int32)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una sottomatrice di caratteri nel flusso.
public:
override void Write(cli::array <char> ^ buffer, int index, int count);
public override void Write (char[] buffer, int index, int count);
override this.Write : char[] * int * int -> unit
Public Overrides Sub Write (buffer As Char(), index As Integer, count As Integer)
Parametri
- buffer
- Char[]
Matrice di caratteri che contiene i dati da scrivere.
- index
- Int32
Posizione del carattere nel buffer da cui iniziare la lettura dei dati.
- count
- Int32
Numero massimo di caratteri da scrivere.
Eccezioni
buffer
è null
.
La lunghezza del buffer meno index
è minore di count
.
index
o count
è negativo.
Si è verificato un errore di I/O.
AutoFlush è true o il buffer di StreamWriter è pieno e il writer corrente è chiuso.
AutoFlush è true o il buffer di StreamWriter è pieno e il contenuto del buffer non può essere scritto nel flusso sottostante di dimensione fissa poiché StreamWriter si trova al termine del flusso.
Esempio
In questo esempio vengono scritti otto caratteri da una matrice di 13 elementi in un file, a partire dal terzo elemento della matrice.
using namespace System;
using namespace System::IO;
int main()
{
FileStream^ sb = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate );
array<Char>^b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
StreamWriter^ sw = gcnew StreamWriter( sb );
sw->Write( b, 3, 8 );
sw->Close();
}
using System;
using System.IO;
public class SWBuff
{
public static void Main(String[] args)
{
FileStream sb = new FileStream("MyFile.txt", FileMode.OpenOrCreate);
char[] b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
StreamWriter sw = new StreamWriter(sb);
sw.Write(b, 3, 8);
sw.Close();
}
}
Imports System.IO
Public Class SWBuff
Public Shared Sub Main()
Dim sb As New FileStream("MyFile.txt", FileMode.OpenOrCreate)
Dim b As Char() = {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c, "g"c, _
"h"c, "i"c, "j"c, "k"c, "l"c, "m"c}
Dim sw As New StreamWriter(sb)
sw.Write(b, 3, 8)
sw.Close()
End Sub
End Class
Commenti
Questo metodo esegue l'override di TextWriter.Write.
I caratteri vengono letti dall'inizio buffer
e index
continuando fino a index
+ (count
- 1). Tutti i caratteri vengono scritti nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso sottostante. Flush viene richiamato automaticamente se AutoFlush è true
.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(String, Object[])
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso, usando la stessa semantica del metodo Format(String, Object[]).
public:
override void Write(System::String ^ format, ... cli::array <System::Object ^> ^ arg);
public override void Write (string format, params object?[] arg);
override this.Write : string * obj[] -> unit
Public Overrides Sub Write (format As String, ParamArray arg As Object())
Parametri
- format
- String
Stringa in formato composito.
- arg
- Object[]
Matrice di oggetti che contiene zero o più oggetti da formattare e scrivere.
Commenti
Per Write(String, Object[]) una descrizione delle funzionalità di formattazione composita offerte, vedere .
Si applica a
Write(Char[])
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una matrice di caratteri nel flusso.
public:
override void Write(cli::array <char> ^ buffer);
public override void Write (char[] buffer);
public override void Write (char[]? buffer);
override this.Write : char[] -> unit
Public Overrides Sub Write (buffer As Char())
Parametri
- buffer
- Char[]
Matrice di caratteri che contiene i dati da scrivere. Se buffer
è null
, non viene scritta alcuna voce.
Eccezioni
Si è verificato un errore di I/O.
AutoFlush è true o il buffer di StreamWriter è pieno e il writer corrente è chiuso.
AutoFlush è true o il buffer di StreamWriter è pieno e il contenuto del buffer non può essere scritto nel flusso sottostante di dimensione fissa poiché StreamWriter si trova al termine del flusso.
Commenti
Questo metodo esegue l'override di TextWriter.Write.
I caratteri specificati vengono scritti nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso. Se AutoFlush è true
, Flush viene richiamato automaticamente.
Questo metodo potrebbe offrire prestazioni più veloci di Write
(char[],``int,``int
) perché contiene meno argomenti da controllare.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(String)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa nel flusso.
public:
override void Write(System::String ^ value);
public override void Write (string value);
public override void Write (string? value);
override this.Write : string -> unit
Public Overrides Sub Write (value As String)
Parametri
- value
- String
Stringa da scrivere nel flusso. Se value
è Null, non viene scritta alcuna voce.
Eccezioni
AutoFlush è true o il buffer di StreamWriter è pieno e il writer corrente è chiuso.
AutoFlush è true o il buffer di StreamWriter è pieno e il contenuto del buffer non può essere scritto nel flusso sottostante di dimensione fissa poiché StreamWriter si trova al termine del flusso.
Si è verificato un errore di I/O.
Commenti
Questo metodo esegue l'override di TextWriter.Write.
L'oggetto specificato String viene scritto nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso.
Flush viene richiamato automaticamente se AutoFlush è true
. Se value
è null
, non vengono scritte voci.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(ReadOnlySpan<Char>)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive un intervallo di caratteri nel flusso.
public:
override void Write(ReadOnlySpan<char> buffer);
public override void Write (ReadOnlySpan<char> buffer);
override this.Write : ReadOnlySpan<char> -> unit
Public Overrides Sub Write (buffer As ReadOnlySpan(Of Char))
Parametri
- buffer
- ReadOnlySpan<Char>
Intervallo di caratteri da scrivere.
Si applica a
Write(Char)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive un carattere nel flusso.
public:
override void Write(char value);
public override void Write (char value);
override this.Write : char -> unit
Public Overrides Sub Write (value As Char)
Parametri
- value
- Char
Carattere da scrivere nel flusso.
Eccezioni
Si è verificato un errore di I/O.
AutoFlush è true o il buffer di StreamWriter è pieno e il writer corrente è chiuso.
AutoFlush è true o il buffer di StreamWriter è pieno e il contenuto del buffer non può essere scritto nel flusso sottostante di dimensione fissa poiché StreamWriter si trova al termine del flusso.
Commenti
Questo metodo esegue l'override di TextWriter.Write.
Il carattere specificato viene scritto nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso. Se AutoFlush è true
, Flush viene richiamato automaticamente.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(String, Object)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso, usando la stessa semantica del metodo Format(String, Object).
public:
override void Write(System::String ^ format, System::Object ^ arg0);
public override void Write (string format, object? arg0);
override this.Write : string * obj -> unit
Public Overrides Sub Write (format As String, arg0 As Object)
Parametri
- format
- String
Stringa in formato composito.
- arg0
- Object
Oggetto da formattare e scrivere.
Commenti
Per Write(String, Object) una descrizione delle funzionalità di formattazione composita offerte, vedere .
Si applica a
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per