我需要在winforms应用程序中上传多个文件。到目前为止,我一直在使用Web客户端,虽然这工作正常,但我想知道是否有更好的方法来做到这一点。 Web客户端是否为每个请求建立新的连接,或者连接在上传之间是否持续?用VB.Net上传多个文件
Dim Ftpclient As New System.Net.WebClient()
Ftpclient.Credentials = New System.Net.NetworkCredential(username, password)
Dim Files As New Dictionary(Of String, String)
''//Fill dictionary with items for upload here
For Each RemoteFile As String In Files.Keys
Ftpclient.UploadFile(RemoteFile, Files(RemoteFile))
Next
这不是FTP的工作方式。但是,System.Net不提供保持打开命令端口连接的替代方法。 – 2009-11-26 20:16:05
当然,但请注意OP创建一个'System.Net.WebClient'实例,而不是'System.Net.FtpWebRequest' – 2009-11-26 20:35:25