Results 1 to 9 of 9

Thread: [2005] open file dialog problem

Hybrid View

  1. #1
    New Member
    Join Date
    Dec 2007
    Posts
    4

    Re: [2005] open file dialog problem

    Dim fileStream As System.IO.FileStream = Nothing
    try that

  2. #2
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] open file dialog problem

    try this

    Code:
    Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim ofd As New OpenFileDialog()
    
        Dim MyValue As String = ""
        ofd.InitialDirectory = "c:\"
        ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
        
        If ofd.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Using sr As New StreamReader(ofd.FileName)
                MyValue = sr.ReadToEnd()
            End Using
        End If
    End Sub
    That should work, and if the file is not found
    use ofd.CheckFilePath, or a property with a similar name which checks the file exists...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width