changing browser behavior about file to browse
Hi to all,
I'd like to display using the webbrowser a html file, but the problem it that file read into web don't have htm or html extension, so webbrowser every time ask me to save file or open with a specific app, so there's a way, using c# to force displaing for all files that browser object meet?
thanks
Kirtan PatelPosted Aug 21, 2009, 8:08 AM
Here I have Written Code for What you want Just Enter A Path of Zip and It Will Interprets as HTML if there is HTML content in it .
i have also included Project Files Link at bottom of post so that you can refer it if you don't understand from the code :)
using System.IO;
private void btnNavigate_Click(object sender, EventArgs e)
{
string URL = txtURL.Text.Trim();
string Extension = Path.GetExtension(URL);
if (Extension == ".zip" | Extension == ".txt")
{
string Data = File.ReadAllText(URL);
StreamWriter sw = new StreamWriter("temp.html");
sw.Write(Data);
sw.Close();
string temppath = Environment.CurrentDirectory + @"\temp.html";
webBrowser1.Navigate(temppath);
}
else
{
webBrowser1.Navigate(URL);
}
}
Download Project Files
paoloPosted Aug 21, 2009, 12:54 PM
paoloPosted Aug 20, 2009, 1:47 PM
Kirtan PatelPosted Aug 20, 2009, 12:35 PM
Provide me the code you are using to access the file :) i will resolve your problem :)