Delen via


PathIO.ReadTextAsync Method

Definition

Overloads

ReadTextAsync(String)

Reads the contents of the file at the specified path or Uniform Resource Identifier (URI) and returns text.

ReadTextAsync(String, UnicodeEncoding)

Reads the contents of the file at the specified path or Uniform Resource Identifier (URI) using the specified character encoding and returns text.

ReadTextAsync(String)

Reads the contents of the file at the specified path or Uniform Resource Identifier (URI) and returns text.

public:
 static IAsyncOperation<Platform::String ^> ^ ReadTextAsync(Platform::String ^ absolutePath);
/// [Windows.Foundation.Metadata.Overload("ReadTextAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<winrt::hstring> ReadTextAsync(winrt::hstring const& absolutePath);
[Windows.Foundation.Metadata.Overload("ReadTextAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<string> ReadTextAsync(string absolutePath);
function readTextAsync(absolutePath)
Public Shared Function ReadTextAsync (absolutePath As String) As IAsyncOperation(Of String)

Parameters

absolutePath
String

Platform::String

winrt::hstring

The path of the file to read.

Returns

IAsyncOperation<String>

IAsyncOperation<Platform::String>

IAsyncOperation<winrt::hstring>

When this method completes successfully, it returns the contents of the file as a text string.

Attributes

Examples

This example shows you how to use readTextAsync(absolutePath) to read text from the file at the path in absoluteFilePath like this:

Windows.Storage.PathIO.readTextAsync(absoluteFilePath).then(function (contents) {
    // Add code to process the text read from the file
});

You can use then or done to declare a function to capture and process the text that was read from the file. After the readTextAsync method completes, the text will be passed to this function as a string object (contents in the example).

See also

Applies to

ReadTextAsync(String, UnicodeEncoding)

Reads the contents of the file at the specified path or Uniform Resource Identifier (URI) using the specified character encoding and returns text.

public:
 static IAsyncOperation<Platform::String ^> ^ ReadTextAsync(Platform::String ^ absolutePath, UnicodeEncoding encoding);
/// [Windows.Foundation.Metadata.Overload("ReadTextWithEncodingAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<winrt::hstring> ReadTextAsync(winrt::hstring const& absolutePath, UnicodeEncoding const& encoding);
[Windows.Foundation.Metadata.Overload("ReadTextWithEncodingAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<string> ReadTextAsync(string absolutePath, UnicodeEncoding encoding);
function readTextAsync(absolutePath, encoding)
Public Shared Function ReadTextAsync (absolutePath As String, encoding As UnicodeEncoding) As IAsyncOperation(Of String)

Parameters

absolutePath
String

Platform::String

winrt::hstring

The path of the file to read.

encoding
UnicodeEncoding

The character encoding of the file.

Returns

IAsyncOperation<String>

IAsyncOperation<Platform::String>

IAsyncOperation<winrt::hstring>

When this method completes successfully, it returns the contents of the file as a text string.

Attributes

See also

Applies to