我试图在计时器中执行 FTPWEBREQUEST,但出现此错误TextBox1.Text = reader.ReadToEnd
Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
你能帮我吗?
谢谢
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
Dim request As FtpWebRequest = CType(WebRequest.Create(""), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
request.Credentials = New NetworkCredential("", "")
Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
Dim ResponseStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(ResponseStream)
'Console.Write(reader.ReadToEnd)
'MessageBox.Show("Directory List Complete, status {0}", response.StatusDescription)
'MessageBox.Show(reader.ReadToEnd)
'MessageBox.Show(reader.ReadToEnd)
TextBox1.Text = reader.ReadToEnd
TextBox1.Text = vbNewLine
TextBox1.Text = vbNewLine
ResponseStream.Close()
reader.Close()
response.Close()
reader.Close()
response.Close()
Timer1.Start()
End Sub
End Class