如何从文本文件c#/.net获取代理?

如何从文本文件c#/.net获取代理?,c#,url,proxy,webbrowser-control,host,C#,Url,Proxy,Webbrowser Control,Host,我在一个文本文件(link.txt)中保存了一些url,在另一个文本文件中保存了一些代理(proxy.txt) 现在我想为每个url使用不同的代理 比如: www.google.com 202.56.232.117:8080 www.facebook.com 506.78.781.987:9001 www.twitter.com 749.961.73.459:8008 这是我的代码,但我不知道如何为每个url使用不同的代理(proxy.txt) 请告诉我怎么做 try { fore

我在一个文本文件(link.txt)中保存了一些url,在另一个文本文件中保存了一些代理(proxy.txt)

现在我想为每个url使用不同的代理

比如:

  • www.google.com 202.56.232.117:8080
  • www.facebook.com 506.78.781.987:9001
  • www.twitter.com 749.961.73.459:8008
这是我的代码,但我不知道如何为每个url使用不同的代理(proxy.txt)

请告诉我怎么做

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();
}
试试这个:

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

我不认为这些行是有效的url-它们有空格,将看起来像是有效url的内容与某种IP地址类型的内容分开(尽管这些行是无效的-八位字节应该只指向255!)IP地址应该是每个url使用的代理吗?这些只是link.txt文件中的示例ulr和proxy.txt文件中的IP地址我想调用这两个文件。第一次调用url&secand调用使用代理加载网页。