Partager via


File.AppendAllTextAsync Méthode

Définition

Surcharges

AppendAllTextAsync(String, String, Encoding, CancellationToken)

Ouvre de façon asynchrone un fichier ou crée le fichier s’il n’existe pas déjà, ajoute la chaîne spécifiée au fichier à l’aide de l’encodage spécifié, puis ferme le fichier.

AppendAllTextAsync(String, ReadOnlyMemory<Char>, Encoding, CancellationToken)
AppendAllTextAsync(String, ReadOnlyMemory<Char>, CancellationToken)
AppendAllTextAsync(String, String, CancellationToken)

Ouvre de façon asynchrone un fichier ou crée un fichier s’il n’existe pas déjà, ajoute la chaîne spécifiée au fichier, puis ferme le fichier.

AppendAllTextAsync(String, String, Encoding, CancellationToken)

Source:
File.cs
Source:
File.cs
Source:
File.cs

Ouvre de façon asynchrone un fichier ou crée le fichier s’il n’existe pas déjà, ajoute la chaîne spécifiée au fichier à l’aide de l’encodage spécifié, puis ferme le fichier.

public static System.Threading.Tasks.Task AppendAllTextAsync (string path, string? contents, System.Text.Encoding encoding, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task AppendAllTextAsync (string path, string contents, System.Text.Encoding encoding, System.Threading.CancellationToken cancellationToken = default);
static member AppendAllTextAsync : string * string * System.Text.Encoding * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function AppendAllTextAsync (path As String, contents As String, encoding As Encoding, Optional cancellationToken As CancellationToken = Nothing) As Task

Paramètres

path
String

Fichier à lequel ajouter la chaîne spécifiée.

contents
String

Chaîne à ajouter au fichier.

encoding
Encoding

Encodage de caractères à utiliser.

cancellationToken
CancellationToken

Jeton à surveiller pour les demandes d’annulation. La valeur par défaut est None.

Retours

Tâche qui représente l’opération d’ajout asynchrone.

Exceptions

Le jeton d’annulation a été annulé. Cette exception est stockée dans la tâche retournée.

Remarques

Cette méthode stocke dans la tâche toutes les exceptions non-utilisation que l’équivalent synchrone de la méthode peut lever. Si une exception est stockée dans la tâche retournée, cette exception est levée lorsque la tâche est attendue. Les exceptions d’utilisation, telles que ArgumentException, sont toujours levées de façon synchrone. Pour les exceptions stockées, consultez les exceptions levées par AppendAllText(String, String, Encoding).

S’applique à

AppendAllTextAsync(String, ReadOnlyMemory<Char>, Encoding, CancellationToken)

public static System.Threading.Tasks.Task AppendAllTextAsync (string path, ReadOnlyMemory<char> contents, System.Text.Encoding encoding, System.Threading.CancellationToken cancellationToken = default);
static member AppendAllTextAsync : string * ReadOnlyMemory<char> * System.Text.Encoding * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function AppendAllTextAsync (path As String, contents As ReadOnlyMemory(Of Char), encoding As Encoding, Optional cancellationToken As CancellationToken = Nothing) As Task

Paramètres

path
String
contents
ReadOnlyMemory<Char>
encoding
Encoding
cancellationToken
CancellationToken

Retours

S’applique à

AppendAllTextAsync(String, ReadOnlyMemory<Char>, CancellationToken)

public static System.Threading.Tasks.Task AppendAllTextAsync (string path, ReadOnlyMemory<char> contents, System.Threading.CancellationToken cancellationToken = default);
static member AppendAllTextAsync : string * ReadOnlyMemory<char> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function AppendAllTextAsync (path As String, contents As ReadOnlyMemory(Of Char), Optional cancellationToken As CancellationToken = Nothing) As Task

Paramètres

path
String
contents
ReadOnlyMemory<Char>
cancellationToken
CancellationToken

Retours

S’applique à

AppendAllTextAsync(String, String, CancellationToken)

Source:
File.cs
Source:
File.cs
Source:
File.cs

Ouvre de façon asynchrone un fichier ou crée un fichier s’il n’existe pas déjà, ajoute la chaîne spécifiée au fichier, puis ferme le fichier.

public static System.Threading.Tasks.Task AppendAllTextAsync (string path, string? contents, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task AppendAllTextAsync (string path, string contents, System.Threading.CancellationToken cancellationToken = default);
static member AppendAllTextAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function AppendAllTextAsync (path As String, contents As String, Optional cancellationToken As CancellationToken = Nothing) As Task

Paramètres

path
String

Fichier à lequel ajouter la chaîne spécifiée.

contents
String

Chaîne à ajouter au fichier.

cancellationToken
CancellationToken

Jeton à surveiller pour les demandes d’annulation. La valeur par défaut est None.

Retours

Tâche qui représente l’opération d’ajout asynchrone.

Exceptions

Le jeton d’annulation a été annulé. Cette exception est stockée dans la tâche retournée.

Remarques

Cette méthode stocke dans la tâche toutes les exceptions non-utilisation que l’équivalent synchrone de la méthode peut lever. Si une exception est stockée dans la tâche retournée, cette exception est levée lorsque la tâche est attendue. Les exceptions d’utilisation, telles que ArgumentException, sont toujours levées de façon synchrone. Pour les exceptions stockées, consultez les exceptions levées par AppendAllText(String, String).

S’applique à