Automatically download from links in browser using c# watin

1k Views Asked by At

Trying to automate file downloads, using Watin in IE. Have a 10 documents to be downloaded and i could find that the below code will prompt for download option.

string download_url="link to file";
browser.Goto(download_url);

I would like to automatically save these files into a new directory with custom names for each files. Is it possible without user prompt for saving files in IE(vesrion 8 and above). Please guide me with a solution for this issue.

1

There are 1 best solutions below

2
ProgrammerV5 On

From your question I can find several other responses right here. Like this one:

Downloading a file with Watin in IE9

using(IE ie = new IE(someUrlToGoTo))
{
    FileDownloadHandler fileDownloadHandler = new FileDownloadHandler(fullFileName);
    ie.AddDialogHandler(fileDownloadHandler);

    ie.Link("startDownloadLinkId").ClickNoWait();

    fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
    fileDownloadHandler.WaitUntilDownloadCompleted(200);
}