I have a really strange situation here: I've written an app that, among other things, switches connections' proxy from on to off and the other way round. It is done by changing the value in the registry:
public void SetUpProxy(string proxy, bool enable)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
if (proxy != null)
key.SetValue("ProxyServer", proxy);
key.SetValue("ProxyEnable", enable ? 1 : 0);
key.Close();
}
When I request enabling the proxy in my app the first thing it does is to connect to ftp server, download a file, THEN enable the proxy (downloading wouldn't work with the proxy on). Everything works perfectly fine - until I launch Internet Explorer.
For example: if I start my app, let it enable the proxy, then let it disable the proxy - everything works fine. But if I enable the proxy, then launch IE, disable proxy and try enabling it again it doesn't work - the app cannot connect to the ftp server because somehow it uses proxy, even though the value in the registry is 0!
I hope I managed to explain it properly. My question is: why is it happening and how can I fix this?
Edit: I'm using WebClient class to download the file. I've found out that client.Proxy.GetProxy(myUri) returns the specified Uri when tha app runs fine, butwhen I open IE it changes to "http://theUriFromIE".