Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have saved some url's in a text(link.txt) file & some proxy(proxy.txt) in another text file.

now i want to use different proxy for each url.

like:

  • www.google.com 202.56.232.117:8080
  • www.facebook.com 506.78.781.987:9001
  • www.twitter.com 749.961.73.459:8008

this is my code but i don't know how to use different proxy(proxy.txt) for each url.

please tell me how to make this work.

try
{

    foreach (string sr in File.ReadAllLines("link.txt"))
    {
        webBrowser1.Navigate(sr);
    }
    webBrowser1.ScriptErrorsSuppressed = true;
    while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
    {
        Application.DoEvents();
    }
}
catch(Exception)
{
     MessageBox.Show("Internet Connection not found","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
     this.Close();
}
share|improve this question
1  
I don't think those lines are valid urls - they have spaces in them, separating what looks like a valid url from some sort of IP-address-type thing (though even those are invalid - the octets should only go to 255!) Are the IP addresses supposed to be the proxies to use for each url? –  ekolis Aug 10 '12 at 22:33
    
these are only example ulr's from link.txt file & IP Addresses from proxy.txt file. & i want to call both files. first call for url & secand call for using proxy to load webpage. –  user1576034 Aug 11 '12 at 3:12

1 Answer 1

try this:

Public Sub SetProxy(ByVal ServerName As String, ByVal port As Integer)
Try            
Dim regkey1 As RegistryKey
regkey1 = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
regkey1.SetValue("ProxyServer", ServerName + ":" + port.ToString(), RegistryValueKind.Unknown)
regkey1.SetValue("ProxyEnable", True, RegistryValueKind.DWord)   
regkey1.Close()
Catch ex As Exception
End Try
End Sub
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.