0

例外が発生した場合にrequestStreamが閉じられて破棄されるかどうかをテストするにはどうすればよいですか?

Try
    Using requestStream As Stream = rqst.GetRequestStream()

        requestStream.Write(fle, 0, fle.Length)

        Throw New ApplicationException("Exception Occured")

    End Using


Catch ex As Exception

    MessageBox.Show(ex.Message.ToString())

Finally
    'test if the requeststream is closed and disposed?
    MessageBox.Show("")

End Try
4

2 に答える 2

3

それUsingがそうです。例外があったとしてもusing、コンパイラfinallyは を呼び出す句を焼き込みますDispose

再度行う必要はありません。

于 2012-11-02T18:21:16.600 に答える