i have inserted some web URL’s in a text file.
Like:
www.google.com
www.facebook.com
www.twitter.com
www.yahoo.com
And I want to browse web page URL form text file in c# webBrowse1 control.
please tell me how it works.
This is my code but it didn’t work.
try
{
FileStream fs = new FileStream("link.txt",FileMode.Open,FileAccess.Read);
StreamReader sr = new StreamReader(fs);
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();
}
Well, the main problem I see is you’re trying to navigate to a stream:
What you probably want to do is loop through the text file and read each line:
This will loop through each line in link.txt and call
Navigate()on each one. I’m not quite sure if that’s what you want, so please clarify if there’s more to this problem.