0
我試着做的FtpWebRequest的計時器,但我得到TextBox1.Text = reader.ReadToEnd
的FtpWebRequest計時器錯誤
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
感謝 - 這就是偉大的 - 一件事TAT我注意到,如果我添加一個新的文件,而我的備考應用程序正在運行它不會顯示新文件的目錄 - 你知道爲什麼嗎?謝謝 –
你的意思是哪個文件?從你的FTP目錄列表或一些本地? –
因此,如果應用程序正在運行並且它輪詢ftp位置並顯示目錄內容。如果我將文件複製到filezilla文件夾中,我希望我的應用程序文本框更新,而它的運行,但它不會..thnaks的幫助 –