How does one use OpenFileDialog in C# in visual Studio 2010
Posted
by xarzu
on Stack Overflow
See other posts from Stack Overflow
or by xarzu
Published on 2010-05-07T16:56:55Z
Indexed on
2010/05/07
16:58 UTC
Read the original article
Hit count: 520
I have written a custom dialog (form) that I can use in a C# program that behaves much like a "File - Open" menu command and brings up a window where a user can select a file or directory.
The question I have is this. It has "My Computer" as its root. How can I have it so that it searches on a Network? If the file or directory is located on a network.
Or better yet, in Visual Studio 2010, is there some sort of canned FileOpenDialog that I can use right away?
I tried calling the OpenFileDialog as described in the example code at http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx but the compiler does not seem to like DialogResult.OK as used in this line of code: if(openFileDialog1.ShowDialog() == DialogResult.OK) The compiler says: Error 1 'System.Nullable' does not contain a definition for 'OK' and no extension method 'OK' accepting a first argument of type 'System.Nullable' could be found (are you missing a using directive or an assembly reference?)
I tried using the namespace Microsoft.Win32 instead of System.Windows.Forms and neither worked. They both produced this error.
© Stack Overflow or respective owner