PathIO.ReadTextAsync 方法

定義

多載

ReadTextAsync(String)

讀取位於指定路徑或統一資源識別項的檔案內容, (URI) 並傳回文字。

ReadTextAsync(String, UnicodeEncoding)

使用指定的字元編碼,讀取位於指定路徑或統一資源識別項 (URI) 檔案的內容,並傳回文字。

ReadTextAsync(String)

讀取位於指定路徑或統一資源識別項的檔案內容, (URI) 並傳回文字。

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)

參數

absolutePath
String

Platform::String

winrt::hstring

要讀取之檔案的路徑。

傳回

IAsyncOperation<String>

IAsyncOperation<Platform::String>

IAsyncOperation<winrt::hstring>

當這個方法順利完成時,它會以文字字串的形式傳回檔案的內容。

屬性

範例

此範例示範如何使用 readTextAsync (absolutePath) ,從路徑 absoluteFilePath 的檔案讀取文字,如下所示:

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

您可以使用 然後完成 來宣告函式,以擷取和處理從檔案讀取的文字。 readTextAsync 方法完成之後,文字會以 字串 物件的形式傳遞至此函式 (contents 範例) 。

另請參閱

適用於

ReadTextAsync(String, UnicodeEncoding)

使用指定的字元編碼,讀取位於指定路徑或統一資源識別項 (URI) 檔案的內容,並傳回文字。

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)

參數

absolutePath
String

Platform::String

winrt::hstring

要讀取之檔案的路徑。

encoding
UnicodeEncoding

檔案的字元編碼。

傳回

IAsyncOperation<String>

IAsyncOperation<Platform::String>

IAsyncOperation<winrt::hstring>

當這個方法順利完成時,它會以文字字串的形式傳回檔案的內容。

屬性

另請參閱

適用於