次の方法で共有


OpenWriteCompletedEventArgs.Result プロパティ

定義

サーバーにデータを送信するために使用される書き込み可能なストリームを取得します。

public:
 property System::IO::Stream ^ Result { System::IO::Stream ^ get(); };
public System.IO.Stream Result { get; }
member this.Result : System.IO.Stream
Public ReadOnly Property Result As Stream

プロパティ値

アップロードするデータを書き込むことができる Stream

次のコード例では、このプロパティによって返されるストリームを使用します。

private static void OpenWriteCallback2(Object sender, OpenWriteCompletedEventArgs e)
{
    Stream body = null;
    StreamWriter s = null;

    try
    {
        body = (Stream)e.Result;
        s = new StreamWriter(body);
        s.AutoFlush = true;
        s.Write("This is content data to be sent to the server.");
    }
    finally
    {
        if (s != null)
        {
            s.Close();
        }

        if (body != null)
        {
            body.Close();
        }
    }
}
Private Shared Sub OpenWriteCallback2(ByVal sender As Object, ByVal e As OpenWriteCompletedEventArgs)

    Dim body As Stream = Nothing
    Dim s As StreamWriter = Nothing

    Try

        body = CType(e.Result, Stream)
        s = New StreamWriter(body)
        s.AutoFlush = True
        s.Write("This is content data to be sent to the server.")
    Finally

        If Not s Is Nothing Then

            s.Close()
        End If

        If Not body Is Nothing Then

            body.Close()
        End If
    End Try
End Sub

注釈

このプロパティによって返されるストリームを使用する前に、 Error プロパティと Cancelled プロパティを確認する必要があります。 Error プロパティの値がException オブジェクトであるか、Cancelled プロパティの値がtrueされている場合、非同期操作が正しく完了せず、Result プロパティの値が無効になります。

適用対象