Hello,
Am using the FTP.Download() method to download contents from a remote folder
Apparently the connection is initiated just fine (by reading the logs) but it always fails at a point in time when reading folder contents.
My remote folder has 3000 files that contains a few more folders and other files inside them. So what happens it that it reads about 490 files (seen from FilesProcessed event) and then it pops this message.
Here is my log
https://www.dropbox.com/s/uouu96kq78mtvju/logs.txt
As far as I could see, it always fails on "Command: CWD /common/battlefield 2/mods/bf2/Levels/OperationHarvest" - folder
My server runs ProFTPd but not sure if that should matter much
Code I use (.net 3.5)
Imports Rebex
Imports Rebex.IO
Imports Rebex.Net
Imports Rebex.Security.Certificates
Imports System.IO
Public Class Form1
Private FTP As Ftp
Dim ip As String = "ip"
Dim port As Integer = "21"
Dim username As String = "username"
Dim password As String = "password"
Dim ssltrue As Rebex.Net.SslMode = SslMode.Explicit
Dim counter As Integer
Private Sub ButtonGreen1_Click(sender As System.Object, e As System.EventArgs) Handles ButtonGreen1.Click
Download()
End Sub
Public Sub Download()
If Not Connect() Then
Return
End If
Try
SetState(True)
If Directory.Exists("download") = False Then
Directory.CreateDirectory("download")
End If
FTP.ChangeDirectory("/common/")
FTP.Download("battlefield 2", "download", TraversalMode.Recursive, TransferMethod.Copy, ActionOnExistingFiles.OverwriteDifferentSize)
Catch ex As Exception
MsgBox(ex.Message)
Finally
Disconnect()
SetState(False)
End Try
End Sub
Private Sub TransferProgressChanged(ByVal sender As Object, ByVal e As FtpTransferProgressChangedEventArgs)
PreloaderProgressBar1.Progress = e.ProgressPercentage
If PreloaderProgressBar1.Progress = 100 Then
ButtonGreen1.Text = "Start Download"
Else
ButtonGreen1.Text = "Downloading..."
End If
Label4.Text = "Files processed " & e.FilesProcessed
Label5.Text = "Speed " & ThreeNonZeroDigits(BytesTO(e.BytesPerSecond, convTo.KB)) & " KB\s"
Label6.Text = "Total downloaded " & ThreeNonZeroDigits(BytesTO(e.BytesTransferred, convTo.MB)) & " MB"
' process any application events to prevent the window from freezing
Application.DoEvents()
End Sub
Private Sub Traversing(ByVal sender As Object, ByVal e As FtpTraversingEventArgs)
Label3.Text = "Total files " & e.FilesTotal
Select (e.TraversingState)
Case TraversingState.HierarchyRetrieving
ButtonGreen1.Text = "Retrieving hierarchy..."
Exit Select
End Select
' process any application events to prevent the window from freezing
Application.DoEvents()
End Sub
Private Sub ButtonBlue1_Click(sender As System.Object, e As System.EventArgs) Handles ButtonBlue1.Click
If Connect() Then
Disconnect()
End If
End
End Sub
Private Function Connect() As Boolean
Try
Cursor = Cursors.WaitCursor
FTP = New Ftp
FTP.Settings.SslAcceptAllCertificates = True
Dim passive As Boolean = CheckBox1.Checked
FTP.Passive = passive
Dim largebuffers As Boolean = CheckBox2.Checked
FTP.LogWriter = New Rebex.FileLogWriter(Application.StartupPath & "\connection_log.log", Rebex.LogLevel.Debug)
FTP.Settings.UseLargeBuffers = largebuffers
FTP.Connect(ip, port, ssltrue)
FTP.Login(username, password)
AddHandler FTP.TransferProgressChanged, AddressOf TransferProgressChanged
AddHandler FTP.Traversing, AddressOf Traversing
Return True
Catch x As Exception
MsgBox(x)
Return False
Finally
Cursor = Cursors.Arrow
End Try
End Function
Private Sub Disconnect()
FTP.Disconnect()
FTP.Dispose()
FTP = Nothing
End Sub
Private Sub SetState(ByVal transferring As Boolean)
If transferring Then
' enable/disable buttons
ButtonGreen1.Enabled = False
CheckBox1.Enabled = False
CheckBox2.Enabled = False
Else
ButtonGreen1.Enabled = True
CheckBox1.Enabled = True
CheckBox2.Enabled = True
End If
End Sub