Click here to Skip to main content
11,716,938 members (86,499 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Forms Console
i have the following code in forms and i need to convert it to a console application... How can i do this?

private void Form1_Load(object sender, EventArgs e)
            WebBrowser wb = new WebBrowser();
            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DisplayText);

            wb.Url = new Uri("");
            wb.Visible = false;
        private void DisplayText(object sender, WebBrowserDocumentCompletedEventArgs e)
            WebBrowser wb = (WebBrowser)sender;
            wb.Document.ExecCommand("SelectAll", false, null);
            wb.Document.ExecCommand("Copy", false, null);
            textResultsBox.Text = Clipboard.GetText();
Posted 28-Sep-12 2:47am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This makes zero sense. A web browser is by nature graphical. How do you propose to use a graphical forms component from a non graphical console? Because you are interacting with the page you get back, there really is no point in doing that.
ridoy at 28-Sep-12 9:30am
right Marcus..+5
Rapsy Tree at 8-Mar-13 5:15am
Really....I am running a console application and running some batch files inside it. At the end, I need to update internal portal and I need a webbrowser control for that. And I believe it perfectly makes sense.
Marcus Kramer at 8-Mar-13 9:44am
You should be updating a web service, not a web page. Either way, you should only need to use the HttpWebRequest classes to achieve this, not an entire web browser control.
Rapsy Tree at 26-Mar-13 11:11am
So I disagree again.....what I said I implemented last week in my project. And I used a web browser control. All I want to say is there are numerous requirements in the world and anything may be valid until someone is asking a code sample to clean swimming pool water.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 659
1 F-ES Sitecore 260
2 Maciej Los 185
3 OriginalGriff 175
4 Richard MacCutchan 140
0 Sergey Alexandrovich Kryukov 1,029
1 Maciej Los 464
2 Richard MacCutchan 430
3 CHill60 415
4 OriginalGriff 415

Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100