4 Replies - 2299 Views - Last Post: 16 November 2009 - 09:05 PM Rate Topic: -----

#1 jcremeans11  Icon User is offline

  • D.I.C Regular

Reputation: 26
  • View blog
  • Posts: 250
  • Joined: 04-October 09

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.
Private Sub debug_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		WebBrowser1.Navigate(Form1.currentfile)


Is This A Good Question/Topic? 0
  • +

Replies To: Webbrowser opening a file automatically

#2 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

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

Was This Post Helpful? 0
  • +
  • -

#3 jcremeans11  Icon User is offline

  • D.I.C Regular

Reputation: 26
  • View blog
  • Posts: 250
  • Joined: 04-October 09

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.
Was This Post Helpful? 0
  • +
  • -

#4 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

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.

Dim filey As String = (Application.StartupPath & "\blah.html")

		File.WriteAllText(filey, TextBox1.Text)
		WebBrowser1.Navigate(filey)



shokin!'s code seems more efficient :D, you won't be wasting any memory.

This post has been edited by LeisureProgrammer: 16 November 2009 - 09:20 PM

Was This Post Helpful? 0
  • +
  • -

#5 shockin!  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 136
  • Joined: 19-October 09

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.
WebBrowser1.DocumentText = TextBox.Text


Tell me how that works :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1