我正在尝试通过将 2 个大文件作为一个文件上传到某个位置来将 2 个大文件上传到 ftp 服务器。如果文件很小,我可以让它工作,但它会因大文件而崩溃。
For i As Integer = 0 To filelist.Count() - 1
Dim fRequest As FtpWebRequest = WebRequest.Create(ftpPath & "/Reports/" & filelist.Item(i))
fRequest.Credentials = New NetworkCredential(username, psswd)
fRequest.KeepAlive = False
fRequest.Proxy = Nothing
fRequest.UsePassive = True
fRequest.UseBinary = True
fRequest.Method = WebRequestMethods.Ftp.DownloadFile
fRequest.Timeout = 30000
Try
' read in file...
' upload file...
Dim fresponse As FtpWebResponse = DirectCast(fRequest.GetResponse(), FtpWebResponse)
Dim fstream As FileStream = fileobj.OpenRead()
Dim sStream As Stream = fRequest.GetRequestStream()
Dim reader As New StreamReader(fstream)
swriter.WriteLine(reader.ReadToEnd)
swriter.Flush()
fstream.Close()
fRequest.Abort()
Catch ex As Exception
appLogs.constructLog(ex.Message.ToString & " @ ", True, True)
errorReporting(ex.Message.ToString & fileItem)
End Try
Next
swriter.Close()
swriter.Dispose()