PathIO.WriteTextAsync Méthode

Définition

Surcharges

WriteTextAsync(String, String)

Écrit le texte dans le fichier au niveau du chemin d’accès spécifié ou de l’URI (Uniform Resource Identifier).

WriteTextAsync(String, String, UnicodeEncoding)

Écrit du texte dans le fichier au niveau du chemin d’accès spécifié ou de l’URI (Uniform Resource Identifier) à l’aide de l’encodage de caractères spécifié.

WriteTextAsync(String, String)

Écrit le texte dans le fichier au niveau du chemin d’accès spécifié ou de l’URI (Uniform Resource Identifier).

public:
 static IAsyncAction ^ WriteTextAsync(Platform::String ^ absolutePath, Platform::String ^ contents);
/// [Windows.Foundation.Metadata.Overload("WriteTextAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncAction WriteTextAsync(winrt::hstring const& absolutePath, winrt::hstring const& contents);
[Windows.Foundation.Metadata.Overload("WriteTextAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncAction WriteTextAsync(string absolutePath, string contents);
function writeTextAsync(absolutePath, contents)
Public Shared Function WriteTextAsync (absolutePath As String, contents As String) As IAsyncAction

Paramètres

absolutePath
String

Platform::String

winrt::hstring

Chemin du fichier dans lequel le texte est écrit.

contents
String

Platform::String

winrt::hstring

Texte à écrire.

Retours

Aucun objet ou valeur n’est retourné lorsque cette méthode est terminée.

Attributs

Exemples

Cet exemple montre comment utiliser [writeTextAsync(absolutePath, contents) pour écrire du texte arbitraire dans un fichier au chemin d’accès dans absoluteFilePath, comme suit :

Windows.Storage.FileIO.writeTextAsync(absoluteFilePath, "Swift as a shadow").then(function () {
    // Add code to do something after the text is written to the file
});

Bien que les méthodes writeTextAsync n’aient pas de valeur de retour, vous pouvez toujours utiliser ensuite ou effectuer pour déclarer une fonction et effectuer des tâches supplémentaires après l’écriture du texte dans le fichier, comme le montre l’exemple.

Remarques

Cette méthode tente de détecter automatiquement l’encodage d’un fichier en fonction de la présence de marques d’ordre d’octet. Si un encodage ne peut pas être détecté, l’encodage spécifié par l’appelant dans la surcharge de méthode est utilisé.

Voir aussi

S’applique à

WriteTextAsync(String, String, UnicodeEncoding)

Écrit du texte dans le fichier au niveau du chemin d’accès spécifié ou de l’URI (Uniform Resource Identifier) à l’aide de l’encodage de caractères spécifié.

public:
 static IAsyncAction ^ WriteTextAsync(Platform::String ^ absolutePath, Platform::String ^ contents, UnicodeEncoding encoding);
/// [Windows.Foundation.Metadata.Overload("WriteTextWithEncodingAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncAction WriteTextAsync(winrt::hstring const& absolutePath, winrt::hstring const& contents, UnicodeEncoding const& encoding);
[Windows.Foundation.Metadata.Overload("WriteTextWithEncodingAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncAction WriteTextAsync(string absolutePath, string contents, UnicodeEncoding encoding);
function writeTextAsync(absolutePath, contents, encoding)
Public Shared Function WriteTextAsync (absolutePath As String, contents As String, encoding As UnicodeEncoding) As IAsyncAction

Paramètres

absolutePath
String

Platform::String

winrt::hstring

Chemin du fichier dans lequel le texte est écrit.

contents
String

Platform::String

winrt::hstring

Texte à écrire.

encoding
UnicodeEncoding

Encodage de caractères du fichier.

Retours

Aucun objet ou valeur n’est retourné lorsque cette méthode est terminée.

Attributs

Voir aussi

S’applique à