我想通过FTP在服务器上使用vb.net发送文件(Vs 2003,框架1.1)抛出异常
在满足要求期间发生的异常
相同的代码在.Net 2008中运行良好。我不知道为什么抛出异常。
Imports System.Data.SqlClient
Imports System.Text
Imports Microsoft.VisualBasic
Imports System.Net.WebRequest
Imports System.Net.WebClient
Imports System.Net
Imports System.IO
If (Directory.Exists(directoryPath)) Then
arrFileList = Directory.GetFiles(directoryPath) '''Getting All files
Else
MessageBox.Show("Directory not Exist")
End If
For i As Integer = 0 To i < arrFileList.Length - 1
Try
Dim fileName As String = arrFileList.GetValue(i)
Dim toUpload As New FileInfo(fileName)
Dim client As New WebClient
Dim nc As New NetworkCredential("xxxx", "xxxx")
Dim addy As Uri
addy = New Uri("ftp://1xx.xx.xxx.xxx/HYPOSII_FTP/Test/" & toUpload.Name.ToString())
client.Credentials = nc
Dim arrReturn As Byte() = client.UploadFile(addy.ToString(), fileName) //This Line Throwing error
MessageBox.Show("File Uploaded Sucessfully")
FLAG = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Next