0 votes
by (120 points)
edited

I have a problem with my program.

When i setup my program to use a proxy for ftp transfer and then afterwards i want to disable the proxy again and what command must i use to clean proxysettings?

when i change the proxytype with: _ftp.Proxy.ProxyType = FtpProxyType.None _ftp.Proxy.Host = Nothing

then program want to use the proxy again, until i restart the program.

Here is the code of proxuse:

        If ProxyEnabled = True Then
            If Trim(ProxyLogin) <> "" Then
                If Trim(ProxyPassword) <> "" Then
                    ProxyPassword = Nothing
                End If
                _ftp.Proxy.ProxyType = ProxyType
                _ftp.Proxy.Host = Proxy
                _ftp.Proxy.Port = ProxyPort
                _ftp.Proxy.UserName = ProxyLogin
                _ftp.Proxy.Password = ProxyPassword
            Else
                _ftp.Proxy.ProxyType = ProxyType
                _ftp.Proxy.Host = Proxy
                _ftp.Proxy.Port = ProxyPort
            End If
        Else
            _ftp.Proxy.ProxyType = FtpProxyType.None
            _ftp.Proxy.Host = Nothing
        End If

would be nice if someone can help me

1 Answer

0 votes
by (58.9k points)
edited

Once you have connected through a proxy, the proxy settings will stay the same untill you Disconnect. So disabling the proxy like this during an established FTP connection

     _ftp.Proxy.ProxyType = FtpProxyType.None

will not take effect untill the Connect method is called again (this is when the Ftp object actually reads the proxy settings.)

So if you want to change proxy settings, just Disconnect() in your program, set the new proxy settings and Connect again:

_ftp.Disconnect()
' set new proxy settings here
_ftp.Connect("server")
_ftp.Login("username", "password")
by (120 points)
edited

Thanks it works like you said :D

sometimes the solution is so easy :D

Best regards Michael

...