dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Need help

  1. #1
    Join Date
    Mar 2010
    Posts
    52

    Need help

    hello all,
    pls be patience to read this, pls

    im doing a project in c#. to automate the downloading process..
    my task is
    1.Login to the website
    2.Click the button on the next page(2nd page)
    3.Click link and then a button on the next page(3rd page)
    4.then the File download dialog box pop ups.


    i ve did the first 3 steps using web browser control in c#. when the File download dialog prompts i got stumbled. getting known from this forum that automate clicking the File download dialog is not possible i am trying now to download the file by specifying its name using webclient in c#. whatever im trying leads to an exception.
    i dont know whether webclient can function in the webbrowser control.

    the code i ve used till is,
    Code:
    private void radioButton1_CheckedChanged(object sender, EventArgs e) 
            { 
                webBrowser1.document.GetElementById("user").InnerText = "xxxxxx"; 
                webBrowser1.document.GetElementById("pass").InnerText = "yyyyyy"; 
                webBrowser1.document.GetElementById("login").InvokeMember("click"); 
                do 
                { 
                    Application.DoEvents(); 
     
                } while (webBrowser1.IsBusy != false); 
                webBrowser1.document.GetElementById("imbutton").InvokeMember("click"); 
                do 
                { Application.DoEvents(); 
                } while (webBrowser1.IsBusy != false); //Inserted my new code here to download directly                
               webBrowser1.document.GetElementById("select").InvokeMember("click"); 
                do 
                { Application.DoEvents(); 
                } while (webBrowser1.IsBusy != false); 
                webBrowser1.document.GetElementById("buttonz").InvokeMember("click"); 
                do 
                { 
                  Application.DoEvents(); 
                } while (webBrowser1.IsBusy != false); 
    }      //Here the File Download Dialog pop ups
    the code i ve inserted new to download the files by name
    Code:
    WebClient myWebClient = new WebClient(); 
    myWebClient.DownloadFile("http:///File.aspx?id=100000", @"d:\xxx.doc");
    this code leads to "The remote server returned an error: (407) Proxy Authentication Required." Exception

    pls guide me in the right path.. where im doing wrong.

    need help pls.

  2. #2
    Join Date
    Apr 2010
    Posts
    131

    Re: Need help

    You can set your Internet Options for automatic download. This will kill the popup window but cause every file to be downloaded in the same place. You would then need to move the file using System.IO

    You can also use a legacy MSXMLHTTP 4.0 component to send a web request, making sure to copy ALL of the header data (including viewstate) into the request first. HTTPWEBREQUEST would do the same thing, but you can no longer modify ALL of the request headers.

    You can use WebReplay software from IEWatch Software. It makes web automation very easy through a scripting-type interface, and can deal with pop-ups. It's commercial, though, so it costs money. http://www.iewatch.com/wrprofessional.aspx

    Hope this helps. Cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)