Solved

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

Posted on 2007-03-21
3
1,038 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now