.net - How to set timeouts for FluentFTP - Stack Overflow

admin2025-05-01  0

I am using Fluent FTP. The documentation says that you set the connection timeout with .ConnectTimeout, but the C# compiler says this is not a member of FTPClient.

How do I set the timeout?

I am using Fluent FTP. The documentation says that you set the connection timeout with .ConnectTimeout, but the C# compiler says this is not a member of FTPClient.

How do I set the timeout?

Share Improve this question edited Jan 8 at 10:13 Martin Prikryl 203k64 gold badges550 silver badges1.1k bronze badges asked Jan 2 at 16:18 PhilPhil 52 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

FTPClient.ConnectTimeout was used in older versions.

Currently, there's FtpConfig.ConnectTimeout. And the FtpConfig goes to the FtpClient constructor.

Here's my fixed code - many thanls to Martin..

Private Function ftp() As FtpClient
Dim c = New FtpClient(optFTPServer, NetCredentials.UserName, NetCredentials.Password)
AddHandler c.ValidateCertificate, AddressOf validateCert
c.Config = New FtpConfig
With c.Config
    .ConnectTimeout = 60000
    .ReadTimeout = 60000
End With
Try
    c.AutoConnect()
Catch ex As Exception
    FTPcatastrophicError = ex.Message
End Try
Return c

End Function

转载请注明原文地址:http://anycun.com/QandA/1746108000a91781.html