Private Sub debug_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WebBrowser1.Navigate(Form1.currentfile)
Webbrowser opening a file automatically
Page 1 of 14 Replies - 1410 Views - Last Post: 16 November 2009 - 09:05 PM
#1
Webbrowser opening a file automatically
Posted 16 November 2009 - 08:28 PM
I'm trying to make an HTML Editing software with vb.net and one of the features is debugging with a webbrowser. I want the webbrowser to open up the file that the user is currently working on. They have to save it before they can open the webbrowser, so possibly it could be webbrowser opens the last save, but this is the best I could come up with.
Replies To: Webbrowser opening a file automatically
#2
Re: Webbrowser opening a file automatically
Posted 16 November 2009 - 08:32 PM
Do you have a Save file dialog whenever you want the user to save their file? If so, then it's easy.
Oh, and make sure you/the user saves it as .html instead of .text (add a filter)
If you don't already have a save file dialog, I suggest you add one, and add this code to any button to save the textfile somewhere.
Oh, and make sure you/the user saves it as .html instead of .text (add a filter)
WebBrowser1.Navigate(SaveFileDialog1.FileName())
If you don't already have a save file dialog, I suggest you add one, and add this code to any button to save the textfile somewhere.
SaveFileDialog1.ShowDialog() File.WriteAllText(SaveFileDialog1.FileName, TextBox1.Text)
This post has been edited by LeisureProgrammer: 16 November 2009 - 08:40 PM
#3
Re: Webbrowser opening a file automatically
Posted 16 November 2009 - 08:43 PM
But how can I make it the specific file that the user was working on? and I already had a save file dialog.
#4
Re: Webbrowser opening a file automatically
Posted 16 November 2009 - 09:03 PM
Force-save the file to your application's startup path, and then use the same path to open it. Example coming in a few minutes.
shokin!'s code seems more efficient
, you won't be wasting any memory.
Dim filey As String = (Application.StartupPath & "\blah.html") File.WriteAllText(filey, TextBox1.Text) WebBrowser1.Navigate(filey)
shokin!'s code seems more efficient
This post has been edited by LeisureProgrammer: 16 November 2009 - 09:20 PM
#5
Re: Webbrowser opening a file automatically
Posted 16 November 2009 - 09:05 PM
Here, try this and tell me how it is, I've tested it w/ some HTML, and it worked fine for me.
Tell me how that works
WebBrowser1.DocumentText = TextBox.Text
Tell me how that works
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|