TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
adam gills
NA
65
14.3k
display urls one by one in webbrowser in C#
Sep 21 2016 1:24 AM
Dear sir ,
I faced an issue to open urls one by one from text file in webbrowser in windows application,
although every time ony one url is display in web browser.
so plz help me where is problems arises.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace demotimer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//WebBrowser wb = sender as WebBrowser;
FileStream fs = new FileStream("D:/Pawan_R&D/timer/demotimer/urls.txt", FileMode.Open, FileAccess.Read);
//StreamReader sr = new StreamReader(fs);
// webBrowser1.Navigate(sr);
//webBrowser1.ScriptErrorsSuppressed = true;
int counter = 0;
string line;
System.IO.StreamReader file =new System.IO.StreamReader("D:/Pawan_R&D/timer/demotimer/urls.txt");
List<string> list=new List<string>();
try
{
webBrowser1.ScriptErrorsSuppressed = true;
while ((line = file.ReadLine()) != null)
{
//Console.WriteLine(line);
// webBrowser1.Navigate(line);
list.Add(line);
counter++;
}
string[] arr = list.ToArray();
Array.Sort(arr);
int i = 0;
for (i = 0; i < 5; i++)
{
webBrowser1.Navigate(arr[i]);
}
file.Close();
//Console.ReadLine();
//foreach (string url in File.ReadAllLines("D:/Pawan_R&D/timer/demotimer/urls.txt"))
//{
// webBrowser1.Navigate(url);
// counter++;
//}
}
catch (Exception)
{
MessageBox.Show("Internet Connection not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//this.Close();
}
}
private void Form1_Load(object sender, EventArgs e)
{
WebBrowser wb = new WebBrowser();
webBrowser1.ScriptErrorsSuppressed = true;
wb.AllowNavigation = true;
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
// wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser2_DocumentCompleted);
// wb.Navigate("http://www.google.com");
//timer1.Start();
}
// private void timer1_Tick(object sender, EventArgs e)
//{
//timer1.Interval = 5000;//5 sec
// timer1.Tick += new System.EventHandler(timer1_Tick);
// webBrowser1.Refresh();
//}
}
}
Reply
Answers (
5
)
kill the Session of User while Loggedin n out in ASP.NET
The resource cannot be found.