问题
Has anybody has done this? Navigating to a web page and pop up the save as dialog? In this way, the browser can handle the file type, html, pdf, etc...
回答1:
Do you need to this to be when a FileHandler is called or on a static webpage?
If it is on a Handler page where the content type is returned then according the latest WatiN release documentation then you can do as follows:
using(IE ie = new IE(someUrlToGoTo))
{
FileDownloadHandler fileDownloadHandler = new FileDownloadHandler(fullFileName);
ie.AddDialogHandler(fileDownloadHandler);
ie.Link("startDownloadLinkId").Click();
fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
fileDownloadHandler.WaitUntilDownloadCompleted(200);
}
Paul
回答2:
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(".pdf");
run this Registry.
来源:https://stackoverflow.com/questions/3546047/show-ie-save-as-dialog-using-watin