PathIO.WriteTextAsync メソッド

定義

オーバーロード

WriteTextAsync(String, String)

指定したパスまたは UNIFORM Resource Identifier (URI) にあるファイルにテキストを書き込みます。

WriteTextAsync(String, String, UnicodeEncoding)

指定した文字エンコードを使用して、指定したパスまたは URI (Uniform Resource Identifier) のファイルにテキストを書き込みます。

WriteTextAsync(String, String)

指定したパスまたは 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

パラメーター

absolutePath
String

Platform::String

winrt::hstring

テキストが書き込まれるファイルのパス。

contents
String

Platform::String

winrt::hstring

書き込むテキスト。

戻り値

このメソッドが完了すると、オブジェクトまたは値は返されません。

属性

この例では、[writeTextAsync(absolutePath, contents) を使用して、 のパス absoluteFilePathにあるファイルに次のように任意のテキストを書き込む方法を示します。

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

writeTextAsync メソッドには戻り値はありませんが、サンプルに示すように、 その後 または 実行 を使用して関数を宣言し、テキストがファイルに書き込まれた後に追加のタスクを実行できます。

注釈

このメソッドは、バイトオーダーマークの存在に基づいてファイルのエンコーディングを自動的に検出しようとします。 エンコードを検出できない場合は、メソッド オーバーロードで呼び出し元によって指定されたエンコードが使用されます。

こちらもご覧ください

適用対象

WriteTextAsync(String, String, UnicodeEncoding)

指定した文字エンコードを使用して、指定したパスまたは URI (Uniform Resource Identifier) のファイルにテキストを書き込みます。

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

パラメーター

absolutePath
String

Platform::String

winrt::hstring

テキストが書き込まれるファイルのパス。

contents
String

Platform::String

winrt::hstring

書き込むテキスト。

encoding
UnicodeEncoding

ファイルの文字エンコード。

戻り値

このメソッドが完了すると、オブジェクトまたは値は返されません。

属性

こちらもご覧ください

適用対象