OpenFileDialog ShowDialog hangs

  • Thread starter Thread starter Tom Harris
  • Start date Start date
T

Tom Harris

Hi there,

has anyone run into this problem? I have a simple winforms app that
uses the OpenFileDialog to open a file. If I choose to open a file
from a different machine on my network everything is fine. However, if
I now close down my app and shutdown the other machine and try again
the OpenFileDialog hangs. The call stack shows that it is waiting in
RunFileDialog.

It looks as though the app persists the current directory somewhere,
but runs into trouble when that path is no longer available. When I
try the same thing with Word it goes back to My Documents when the
network path is not available.

Any ideas?

Thanks,

Tom
 
Hi Tom,

I have seen this hanging in an old version of Media Player - so it is not a
pure .NET problem. Actually, it does not hang - it just waits for several
minutes until network connection times out. You could possibly avoid the
waiting by disabling this feature on the OpenFileDialog (it should have a
boolean property called something like RestoreDirectory) and providing
similar functionality manually - with a view of probing the stored path if
it is a network one before showing the Open File dialog.
 
Hi,

many thanks for your help. I think you're right about what is
happening. It would certainly be nice if it didn't wait for several
minutes!

Do you know how I can fine out the directory that the OpenFileDialog
is going to try and go to before I run the dialog to do the check. The
OpenFileDialog will allow me to set the InitialDirectory, but not find
out what it's current value is.

Thanks,

Tom

Dmitriy Lapshin said:
Hi Tom,

I have seen this hanging in an old version of Media Player - so it is not a
pure .NET problem. Actually, it does not hang - it just waits for several
minutes until network connection times out. You could possibly avoid the
waiting by disabling this feature on the OpenFileDialog (it should have a
boolean property called something like RestoreDirectory) and providing
similar functionality manually - with a view of probing the stored path if
it is a network one before showing the Open File dialog.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Tom Harris said:
Hi there,

has anyone run into this problem? I have a simple winforms app that
uses the OpenFileDialog to open a file. If I choose to open a file
from a different machine on my network everything is fine. However, if
I now close down my app and shutdown the other machine and try again
the OpenFileDialog hangs. The call stack shows that it is waiting in
RunFileDialog.

It looks as though the app persists the current directory somewhere,
but runs into trouble when that path is no longer available. When I
try the same thing with Word it goes back to My Documents when the
network path is not available.

Any ideas?

Thanks,

Tom
 
Back
Top