VB FTP 代码问题
Public Class Form1
Dim wc As New Net.WebClient
Dim passwort As String = "密码"
Dim benutzername As String = "用户名"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Control.CheckForIllegalCrossThreadCalls = False
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Try
wc.Credentials = New Net.NetworkCredential(benutzername, passwort)
TextBox1.Text = wc.DownloadString("ftp://***.com/chat.txt")
Catch ex As Exception
MessageBox.Show("Error!")
End Try
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub sentannui_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sentannui.Click
BackgroundWorker2.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork
BackgroundWorker1.CancelAsync()
wc.Credentials = New Net.NetworkCredential(benutzername, passwort)
wc.UploadString("ftp://***.com/chat.txt", TextBox1.Text & "" & TextBox0.Text & ": " & TextBox2.Text & vbNewLine) '这一句出现的错误,用户代码未处理 NotSupportedException. WebClient does not support concurrent I/O operations.请问有什么解决方法吗?
Try
wc.Credentials = New Net.NetworkCredential(benutzername, passwort)
TextBox1.Text = wc.DownloadString("ftp://***.com/chat.txt")
Catch ex As Exception
MessageBox.Show("Error!")
End Try
End Sub
Private Sub BackgroundWorker2_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker2.RunWorkerCompleted
TextBox2.Clear()
BackgroundWorker1.RunWorkerAsync()
End Sub
End Class
--------------------编程问答--------------------
学校的作业制作简单的Ftp聊天,不太懂出错的意思,请问有什么解决方法吗?
补充:VB , 基础类