?
Solved

InternetExplorer object (SHDocVw.dll) for IE Automation

Posted on 2004-08-24
7
Medium Priority
?
793 Views
Last Modified: 2012-06-27
I am working on a project where I need to automate IE.  I am writing the application in C# and controlling the browser using the InternetExplorer object (SHDocVw.dll).  So far I have been able to do everything I need to do (navigate to a particular site/page, manipulate elements on the page, populate form objects, submit forms, etc.).  However, I would like to be able to automate the process of saving files that are linked on a site.  For instance on the website are links to .pdf files, .csv files, word files, excel files, images, etc. that I need to download to the local drive.  If I attempt to access the files by their URL/Path on the website, the browser spawns the Open/Save dialog box, of which I have not been able to determine how to interact with.  And the "Always ask this" checkbox doesn't seem to make a difference.

I do not think I can use .NET's WebRequest/HttpWebRequest objects because I need to automate a login process on the site in order to access the files.  That's why I'm using IE Automation.  I cannot use WSH (Windows Scripting Host) as this application does contain other business rules and specialized functionality.

Basically my questions are:  
1.  using IE Automation (using the InternetExplorer object) can I download files (text or binary) from a site to the local machine.  Whether I interact with the Open/Save dialog box spawned by IE or access and download the files via another means, I do not care.  
2.  When IE spawns a dialog window (i.e. Open/Save, Windows Authentication, etc.) how can you interact with it (i.e. click "Save", fill in the login/password boxes, etc.).

If you know of a better way to do what I'm trying to do, please let me know.

I appreciate your help.  Thanks.
 
0
Comment
Question by:jkaina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 15

Expert Comment

by:Timbo87
ID: 11887195
You can pass credentials to WebClient objects.

WebClient wc = new WebClient();
wc.Credentials = new NetworkCredential("username", "password", "domain");
wc.DownloadFile("http://www.example.com/file.pdf", @"c:\file.pdf");
0
 

Author Comment

by:jkaina
ID: 11887298
Actually, the site uses a proprietary login.  Basically it stores usernames and passwords in a database, upon login/validation, session variables are set, etc.  So it's not using windows authentication.  That's why I was trying IE Automation.  Anyhow, thank you for the response though.  I do appreciate your input.

I ended up figuring out how I could do it.  But again, thank you for the help.
0
 

Author Comment

by:jkaina
ID: 11887431
By the way... for the curious, the way i got this to work was to use DllImport to reference UrlMon and call the UrlDownloadToFile() method.  Thanks goes out to jkr for steering me in the right direction.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 11933617
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Moderator
0
 
LVL 4

Expert Comment

by:brokeMyLegBiking
ID: 12236254
jkaina, I am trying to perform the same opperation of downloading files. I am encouraged by the fact that you were able to make it work. Do you mind posting a few more links on IE interaction, perhaps some of your sample code? I will have posted another question which you can respond to:  http://Q_21157773.html

Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question