Initialize OpenFileDialog

  • Thread starter Thread starter barbara_dave
  • Start date Start date
B

barbara_dave

Hi, All,

I want to use the openfiledialog to open different extension files in
different directory( only one type files at one time). I set the
OpenFiledialog InitialDirectory and Filter property for ".dat" files at
first time, it works. When I try to use openfiledialog to set different
InitialDirectory an different Filter property for ".txt" files at
second time, I got frozen window. Even I added code to dispose
openfiledialog after using it, I still got frozen window. How to use
OpenFileDialog to open one type file in a directory and open another
type file in another directory next time?
Thinks a lot for your time and help!
 
Can you post some simplied code that shows the problem?

chris
 
This works for me... Why are you disposing of the obj if you want to use it
again? That's not a good idea unless you New it again.

This works for me.

Dim X As New OpenFileDialog
X.InitialDirectory = "C:\Windows"
X.Filter = "(*.txt)|*.txt"
X.ShowDialog()
X.InitialDirectory = "C:\Windows\System32"
X.Filter = "(*.dll)|*.dll"
X.ShowDialog()

Chris
 
Thanks, Chris.

It is working for me now.

The reason I got error is when I am using three buttons to control
openFileDialog for three type files, I defined X as new OpenFileDialog
three times, the system displayed "can't handle...". So, I changed code
to define X only once, and reset initialDirectory and Filter when press
different buttons. It works.

Thanks, again.
 
Back
Top