如何将ip-address传递给webBrowser控件

时间:2012-08-20 13:13:17

标签: c# .net ip webbrowser-control ip-address

如何将IPAddress传递给webBrowser控件

这是我的代码,但我不知道如何将ip-address传递给webBrowser控件。

IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (string line in File.ReadAllLines("proxy.txt"))
{
    IPAddress ip = IPAddress.Parse(line);
    if (ip.AddressFamily.ToString() == "InterNetwork")
    {
        localIP = ip.ToString();
        textBox1.Text = ip.ToString();

        // This code doesn't work, it's just a hypothetical example:
        webBrowser1.SourceIPAddress=ip; 

        webBrowser1.Navigate(textBox2.Text);
    }
}

这就是我想把ip-address传递给webBrowser控件的方法

//The code doesn't work, it's just a hypothetical example:
webBrowser1.SourceIPAddress = ip;

2 个答案:

答案 0 :(得分:4)

只需在文本框http://74.125.236.211

中书写

textBox2.Text="http://74.125.236.211"

答案 1 :(得分:0)

你真正想做的事情对我来说并不清楚,但我会猜测一下,假设您希望使用代理服务器在textBox2.Text下载网址,并希望在文件{{中尝试代理1}}直到一个成功地工作。

proxy.txt