none
Visual Basic 2010 Help! "Empty Path Name Is Not Legal" RRS feed

  • Question

  • Hello , I am new to visual basic 2010 and programming and i feel stupid . I was making a simple html editor with : New , Open , Save , Preview And Of course the text box . . . so i got this error "Empty Path Name Is Not Legal"
    Here Is The Code :
    -------------------------------------------------
    Public Class Form1
        Private Sub ToolStripSeparator1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripSeparator1.Click
        End Sub
        Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
        End Sub
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.RichTextBox1.Text = "<!DOCTYPE html>" & vbCrLf & "<html>" & vbCrLf & "<head>" & vbCrLf & "</head>" & vbCrLf & "<body>" & vbCrLf & "</body>" & vbCrLf & "</html>"
        End Sub
        Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
            Me.RichTextBox1.Text = "<!DOCTYPE html>" & vbCrLf & "<html>" & vbCrLf & "<head>" & vbCrLf & "</head>" & vbCrLf & "<body>" & vbCrLf & "</body>" & vbCrLf & "</html>"
            Me.Text = "Fldr Html Editor"
        End Sub
        Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
            OpenFileDialog1.Filter = "All Files(*) | *"
            OpenFileDialog1.ShowDialog()
            RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)
            Me.Text = OpenFileDialog1.FileName
        End Sub
        Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
            SaveFileDialog1.Filter = "All Files(*) | *"
            SaveFileDialog1.ShowDialog()
            RichTextBox1.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Form2.WebBrowser1.DocumentText = Me.RichTextBox1.Text
            Form2.Show()
        End Sub
        Private Sub CreditsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreditsToolStripMenuItem.Click
            MsgBox("This Software 'Basic Html Editor Beta v0.9' Was Made By The Developers Team Of GreenBasicSoftwares ! Visit Our Website For More Information : www.GreenBasicSoftwares.tk! Thank You!")
        End Sub
        Private Sub SupportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SupportToolStripMenuItem.Click
            MsgBox("Please Support GreenBasicSoftwares At Our Website By Liking , Google +1 , Adding Comments And Leaving Suggestions or Reporting Bugs ! We Would Really Appreciate Your Support And Give Great Offers On Advanced Softwares On Which Our Developers Team Is Working On !")
        End Sub
        Private Sub ProblemsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProblemsToolStripMenuItem.Click
            MsgBox("If You Have Any Problems Than Just Please Visit Our Website 'www.GreenBasicSoftwares.com' And From The Contact Section Send Us An Email Or Live Chat If Any Customer-Support Member Is Online And We Will Try Our Best To Help You ! Thank You !")
        End Sub
        Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
            Application.Exit()
        End Sub
    End Class
    -------------------------------------------------
    The Small Text Part Of The Whole Code Which I Have Underlined And Made It Bold Is Where I Was Getting The Error "Empty Path Name Is Not Legal" ! Please Can You Explain It To Me A Bit Instead Of Just Giving The Solution , Do Give The Solution But Please Give A Brief Explanation Too And Maybe A Website Also From Where I Can Learn More About Programming ( For Beginners ) !  Thank You :) !
    Monday, March 25, 2013 2:47 PM

Answers

  • Explanation: When calling SaveFileDialog1.ShowDialog(), check that the return value is OK. Otherwise, the user might have pressed "Cancel" and therefore the FileName is empty, producing an error when the next line attempts to Save.

    Suggestion: This is the Training and Certification forum. I suggest that you post this kind of questions in one of the programming forums in MSDN:

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads

    Wednesday, March 27, 2013 8:09 AM