Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have the following code in forms and i need to convert it to a console application... How can i do this?

C#
private void Form1_Load(object sender, EventArgs e)
        {
            WebBrowser wb = new WebBrowser();

            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DisplayText);


            wb.Url = new Uri("http://www.dut.ac.za");
            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

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.
 
Share this answer
 
Comments
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.
fjdiewornncalwe 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900