PathIO.WriteTextAsync Method

Definition

Overloads

WriteTextAsync(String, String)

Writes text to the file at the specified path or Uniform Resource Identifier (URI).

WriteTextAsync(String, String, UnicodeEncoding)

Writes text to the file at the specified path or Uniform Resource Identifier (URI) using the specified character encoding.

WriteTextAsync(String, String)

Writes text to the file at the specified path or Uniform Resource Identifier (URI).

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

Parameters

absolutePath
String

Platform::String

winrt::hstring

The path of the file that the text is written to.

contents
String

Platform::String

winrt::hstring

The text to write.

Returns

No object or value is returned when this method completes.

Attributes

Examples

This example shows you how to use [writeTextAsync(absolutePath, contents) to write some arbitrary text to a file at the path in absoluteFilePath, like this:

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

Although the writeTextAsync methods don't have a return value, you can still use then or done to declare a function and perform additional tasks after the text is written to the file, as the sample shows.

Remarks

This method attempts to automatically detect the encoding of a file based on the presence of byte order marks. If an encoding cannot be detected, the encoding specified by the caller in the method overload is used.

See also

Applies to

WriteTextAsync(String, String, UnicodeEncoding)

Writes text to the file at the specified path or Uniform Resource Identifier (URI) using the specified character encoding.

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

Parameters

absolutePath
String

Platform::String

winrt::hstring

The path of the file that the text is written to.

contents
String

Platform::String

winrt::hstring

The text to write.

encoding
UnicodeEncoding

The character encoding of the file.

Returns

No object or value is returned when this method completes.

Attributes

See also

Applies to