opening a file with internet explorer from C# code?
-
Hello, I'm creating a dialog with a small list of files, where the user can add/remove arbitrary files via an open file dialog. What I want is for the user to be able to dblclick an item in the list, and bring up that file in internet explorer (assuming there is a plug-in installed for the given file type, otherwise I guess IE would show a warning. How can this be done? CommandLine argument? Is there such a thing as an internet explorer control available that I can embed easily? Otherwise just an IE window popping up would do the job for me equally well..
-
Hello, I'm creating a dialog with a small list of files, where the user can add/remove arbitrary files via an open file dialog. What I want is for the user to be able to dblclick an item in the list, and bring up that file in internet explorer (assuming there is a plug-in installed for the given file type, otherwise I guess IE would show a warning. How can this be done? CommandLine argument? Is there such a thing as an internet explorer control available that I can embed easily? Otherwise just an IE window popping up would do the job for me equally well..
-
Hello, I'm creating a dialog with a small list of files, where the user can add/remove arbitrary files via an open file dialog. What I want is for the user to be able to dblclick an item in the list, and bring up that file in internet explorer (assuming there is a plug-in installed for the given file type, otherwise I guess IE would show a warning. How can this be done? CommandLine argument? Is there such a thing as an internet explorer control available that I can embed easily? Otherwise just an IE window popping up would do the job for me equally well..
misterbear wrote: Is there such a thing as an internet explorer control available that I can embed easily? IE can be embedded as an ActiveX control within your application. If you add the "Microsoft Web Browser Control" COM Component (shdocvw.dll) to your Toolbox, you'll be able to insert that on your form. To visit a website, call the control's Navigate function. The Web Browser control is heavily documented on MSDN, and many examples exist on the 'net for showing some of the advanced things you can do with it.
-
Why, don't you just use Process.Start () and open the fil in the default application? Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
yes I could, but the application that will eventually use the files on this list (not the same as mine) might not have the same default applications. And that app will also want to start the files listed here in IE through plug-ins. So I need to supply the same functionality here...
-
yes I could, but the application that will eventually use the files on this list (not the same as mine) might not have the same default applications. And that app will also want to start the files listed here in IE through plug-ins. So I need to supply the same functionality here...
I really don't get why you need to view the files in a browser. Why would you, for instance, like to open a pdf in a browser. If he has a plugin for the browser you can be shure he has a standalone application for that file type. Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
-
Hello, I'm creating a dialog with a small list of files, where the user can add/remove arbitrary files via an open file dialog. What I want is for the user to be able to dblclick an item in the list, and bring up that file in internet explorer (assuming there is a plug-in installed for the given file type, otherwise I guess IE would show a warning. How can this be done? CommandLine argument? Is there such a thing as an internet explorer control available that I can embed easily? Otherwise just an IE window popping up would do the job for me equally well..
In addition to what CWIZO and John said, you can interop shdocvw.dll by using tlbimp.exe or VS.NET (add a COM reference to your project for the Microsoft Web Browser library) and use the
InternetExplorer
class to load a file. This will create a new instance of IE or use an existing instance (the fore-most instance, IIRC) to display the HTML (or whatever IE-handled file). UsingProcess.Start
with a filename (works likeShellExecute(Ex)
) will use the default browser, but if you want to make sure they use IE (maybe the HTML files are scripted only for IE, for example) use theInternetExplorer
object or useProcess.Start("iexplore.exe", _pathToHtmlFile_)
.Microsoft MVP, Visual C# My Articles