Page 1 of 1

OpenFileDialog Shows Twice?

Posted: Sat Jul 17, 2010 10:33 pm
by GoodGuy17
Hello,
I am using the following code from what I assume is correct.
Code: Select all
        OpenFileDialog1.ShowDialog()
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim Reader As New System.IO.StreamReader(OpenFileDialog1.FileName)
            TextBox1.Text = Reader.ReadToEnd
        End If
I have this problem: After you select a file and click open, it shows the dialog again. Then, you select it again and click open, and it works. Can somebody tell me why this happens? And how to fix it?

Re: OpenFileDialog Shows Twice?

Posted: Sat Jul 17, 2010 11:34 pm
by mandai
The reason for this is because ShowDialog is being called twice.
Get rid of the first line to solve this problem.

Re: OpenFileDialog Shows Twice?

Posted: Sun Jul 18, 2010 7:35 pm
by GoodGuy17
Thanks mandai!