Initialize OpenFileDialog

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!
 
C

Chris, Master of All Things Insignificant

Can you post some simplied code that shows the problem?

chris
 
C

Chris, Master of All Things Insignificant

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
 
B

barbara_dave

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top