Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. opening a file with internet explorer from C# code?

opening a file with internet explorer from C# code?

Scheduled Pinned Locked Moved C#
csharpquestioncareer
6 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    misterbear
    wrote on last edited by
    #1

    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..

    C U H 3 Replies Last reply
    0
    • M misterbear

      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..

      C Offline
      C Offline
      CWIZO
      wrote on last edited by
      #2

      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!

      M 1 Reply Last reply
      0
      • M misterbear

        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..

        U Offline
        U Offline
        User 1172745
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • C CWIZO

          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!

          M Offline
          M Offline
          misterbear
          wrote on last edited by
          #4

          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...

          C 1 Reply Last reply
          0
          • M misterbear

            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...

            C Offline
            C Offline
            CWIZO
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            0
            • M misterbear

              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..

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              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). Using Process.Start with a filename (works like ShellExecute(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 the InternetExplorer object or use Process.Start("iexplore.exe", _pathToHtmlFile_).

              Microsoft MVP, Visual C# My Articles

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups