Click here to Skip to main content
11,922,877 members (48,456 online)
Rate this:
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 3: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 28-Sep-12 9:30am
right Marcus..+5
Rapsy Tree 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151125.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