Disable a previous setuped Proxy

0 votes
asked May 21, 2013 by rieco (120 points)
edited May 22, 2013

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
answered May 22, 2013 by Tomas Knopp (58,890 points)
edited May 22, 2013

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")
commented May 22, 2013 by rieco (120 points)
edited May 22, 2013

Thanks it works like you said :D

sometimes the solution is so easy :D

Best regards Michael

Welcome to Q&A forum for C# and VB.NET developers working with following .NET components:

If you need immediate assistance, please contact us directly.

...