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
  1. Home
  2. General Programming
  3. C#
  4. Open XML file in a browser

Open XML file in a browser

Scheduled Pinned Locked Moved C#
xmlhelp
4 Posts 4 Posters 0 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.
  • I Offline
    I Offline
    immu5
    wrote on last edited by
    #1

    I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....

    G S V 3 Replies Last reply
    0
    • I immu5

      I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....

      S Offline
      S Offline
      Sylvester george
      wrote on last edited by
      #2

      FileStream fileStream = new FileStream("c:\\dat.xml", FileMode.OpenOrCreate, FileAccess.Read); long len; len = fileStream.Length; Byte[] fileAsByte = new Byte[len]; fileStream.Read(fileAsByte, 0, fileAsByte.Length); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.Buffer = true; Response.ContentType = "text/xml"; Response.BinaryWrite(fileAsByte); Response.Flush(); Response.End();

      Regards, Sylvester G sylvester_g_m@yahoo.com

      1 Reply Last reply
      0
      • I immu5

        I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        Which button? A button on the form? If yes then add an event handler for the button and use Process class to open browser and pass the xml file as a parameter.

        my articles

        1 Reply Last reply
        0
        • I immu5

          I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....

          V Offline
          V Offline
          Vikram A Punathambekar
          wrote on last edited by
          #4

          Not sure why you'd want to open the file in a specific application but the best way to open a file using the associated program is

          System.Diagnostics.Process.Start("PathToYourFile");

          If you really, REALLY know what you are doing and want to open it in a specific application, it will most likely support command line arguments.

          System.Diagnostics.Process.Start("ApplicationPath", "PathToYourFile");

          Cheers, Vıkram.


          After all is said and done, much is said and little is done.

          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