Solved

Custom Open File Dialog in .NET to open a directory as a file

Posted on 2007-03-21
3
1,052 Views
Last Modified: 2013-11-26
I am programming this in VB.NET 2005, Is there a way to use the open file dialog box to open a folder like a file?  Meaning, I am using a product that stores its databases in a directory with an extension example: MyDB.gdb, so if I use OpenFileDialog, it opens it like it would any other Directory I need to be able to tell it that .gdb is a file and when they click open it selects it like it would a File and return back a path to the "file"
0
Comment
Question by:davidtrina
  • 2
3 Comments
 
LVL 6

Expert Comment

by:kerryw60
ID: 18767219
Not certain I'm following your question, but could you not:

With ofd
   .InitialDirectory = "C:\"
   .Title = "Select a database"
   .FileName = ""
   .Filter = "Database (*.gdb)|*.gdb
   .FilterIndex = 1
End With

If ofd.ShowDialog <> System.Windows.Forms.DialogResults.Cancel Then
   Dim strMyPath as String = ofd.FileName
   'Then whatever else you want to do...
End If
0
 
LVL 1

Author Comment

by:davidtrina
ID: 18768851
Ok... the .GDB "file" is in fact NOT a file it is a directory that I want to treat like a file
0
 
LVL 6

Accepted Solution

by:
kerryw60 earned 250 total points
ID: 18771023
Only other options are:

1) FolderBrowserDialog, but you cannot filter to show a "file" extention for folders.

2) Create your own custom control, with dialog, to behave how you want.

Very sorry I cannot help you further.

Good Luck!!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question