Open XML file in a browser
-
I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....
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
-
I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....
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.
-
I have a XML file. I want to open that XML file in browser, when i click on the button. Help me out.....
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.