Hi,
Please find the code and the error.
_ftpConnection.Connect() FAILS
Can you please advice how to fix this problem
Thanks
Praveen
Private Sub ConnectFTP()
Try
'Setup ftp and connect.
_ftpConnection.ServerAddress = Config.FtpServer
_ftpConnection.ServerPort = Config.FtpServerPort
_ftpConnection.UserName = Config.FtpUser
_ftpConnection.Password = Config.FtpPassword
'This setting is not working, the event is still firing based upon the default of 4096 bytes.
_ftpConnection.TransferNotifyInterval = 1000
If Config.FtpPassiveMode Then
_ftpConnection.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV
Else
_ftpConnection.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.ACTIVE
End If
ApplicationLog.Log("FTP Passive mode: " & Config.FtpPassiveMode)
_ftpConnection.Connect()
If Config.FtpFolder <> "" Then
_ftpConnection.ChangeWorkingDirectory(Config.FtpFolder)
End If
Catch ex As Exception
If _ftpConnection.IsConnected Then
_ftpConnection.Close()
End If
ApplicationLog.Log(ex.ToString)
End Try
End Sub
The ERROR I get is:
System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at EnterpriseDT.Net.StandardSocket.Connect(EndPoint remoteEP)
at EnterpriseDT.Net.Ftp.FTPControlSocket.ConnectSocket(BaseSocket socket, IPAddress address, Int32 port)
at EnterpriseDT.Net.Ftp.FTPControlSocket.Initialize(BaseSocket sock, IPAddress remoteHost, Int32 controlPort, Int32 timeout)
at EnterpriseDT.Net.Ftp.FTPControlSocket..ctor(IPAddress remoteHost, Int32 controlPort, Int32 timeout)
at EnterpriseDT.Net.Ftp.FTPClient.Connect(IPAddress remoteAddr, Int32 controlPort, Int32 timeout)
at EnterpriseDT.Net.Ftp.FTPClient.Connect()
at EnterpriseDT.Net.Ftp.FTPConnection.Connect()
at DCube.Ftp.ConnectFTP() in C:\M1Projects\DCube.root\DCube\Ftp.vb:line 37" String