i am using an open file dialog in visual basic to open the file ,the user has to click open twice to open the file(in the first click the dialog refreshes with the selected filename) what should i do i want the user to click only once to open the file.Heres the code i used
OpenFileDialog1.FileName = ""
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim c As String = Me.OpenFileDialog1.FileName
Dim cc As String = IO.File.ReadAllText(c)
Me.RichTextBox1.Text = cc
Else
End If
Open File Dialog help in visual basic 2005?
Try
With OpenFileDialog1
.Filter = "Text files (*.txt)|*.txt|" %26amp; "All files|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
sr = New StreamReader(.OpenFile)
RichTextBox1.Text = sr.ReadToEnd()
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (sr Is Nothing) Then
sr.Close()
End If
End Try
the above code is to read the given txt file from open dialog box and then showing the text file content in the richtext box..
the above code is in vs2003 .. the similar way only u can do it in vs 2005 not much different ..
hope u got ur answer...
keep askin question
regards
rajan
poppy
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment