我想从一个文件中读取,如果我失败了,让用户重试或以其他方式放弃.到目前为止代码看起来像这样:
@H_502_1@Read_Again:
Try
my_stream.Read(buffer,read_len)
Catch ex As System.IO.IOException
If MessageBox.Show("try again?") = DialogResult.Retry Then
GoTo Read_Again
Else
Application.Exit() 'just abort,doesn't matter
End If
End Try
我不喜欢Goto,这很难看.但我不知道如何制作一个跨越try和catch的循环.
有没有更好的方法来写这个?