| Author: Nagarajan 12 Aug 2008 | Member Level: Gold | Rating: Points: 3 |
Try this , instead of creating a FileDialog in coding, try dragging a FileDIalog control in the design view iteself,
so that you can use it in your code with out instantiating it.
|
| Author: ksdkarthikeyan 12 Aug 2008 | Member Level: Silver | Rating: Points: 4 |
dim value as boolean
copy below code and paste in Load events
value = Control.CheckForIllegalCrossThreadCalls Control.CheckForIllegalCrossThreadCalls = False
i fixed the error.. this is useful for others whose faced this error thank you.
|
| Author: Geetha 12 Aug 2008 | Member Level: Gold | Rating: Points: 6 |
Private FileName As String 'declaring filename that will be selected Dim sr As StreamReader 'streamreader is used to read text
Try With OpenFileDialog1 'With statement is used to execute statements using a particular object, here,_ 'OpenFileDialog1 .Filter = "Text files (*.txt)|*.txt|" & "All files|*.*" 'setting filters so that Text files and All Files choice appears in the Files of Type box 'in the dialog If .ShowDialog() = DialogResult.OK Then 'showDialog method makes the dialog box visible at run time FileName = .FileName sr = New StreamReader(.OpenFile) 'using streamreader to read the opened text file RichTextBox1.Text = sr.ReadToEnd() 'displaying text from streamreader in richtextbox 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
|