2

I have a VB/C# .NET 2.0 project that, if possible, I would like to customize the OpenFileDialog box to select a directory rather than a file. The reason for this is because the FolderBrowserDialog is ugly and a pain for most of my users to navigate using.

I know how to filter extensions using OpenFileDialog, but is there a flag or variable I can set that will allow me to only show directories and select those directories that is built into .NET? And if not, what is a good third party dialog to use/where should I begin if I am to create my own?

I apologize, I do not have much experience creating frontends. Any help or direction on this would be greatly appreciated :)

codewario
  • 19,553
  • 20
  • 90
  • 159
  • possible duplicate of [How do you configure an OpenFileDIalog to select folders?](http://stackoverflow.com/questions/31059/how-do-you-configure-an-openfiledialog-to-select-folders) – Bradley Grainger Jan 21 '11 at 16:25
  • See http://stackoverflow.com/a/15456640/117870 which links to [this article](http://www.lyquidity.com/devblog/?p=136 ".NET Win 7-style folder select dialog") for a working solution – Alex Essilfie Jun 09 '13 at 15:15

1 Answers1

0

After checking the question that Mayank posted, I found out that there is no native way to do this in .NET. However, one of the posts by Scott Wisniewski yielded the exactly what I was looking for.

The only thing I had to do to make this work in .NET 2.0 was add the following code to my project in a file called ExtensionAttribute.cs. This method is not needed in .NET 3.5+, but please note that this is reported to not work at all with Visual Studio 2005.

namespace System.Runtime.CompilerServices
{
   [AttributeUsage(AttributeTargets.Method)]
   public sealed class ExtensionAttribute : Attribute
   {
      public ExtensionAttribute() { }
   }
}

Again, this code snippet only works with Visual Studio 2008, it will not work with VS 2005.

Community
  • 1
  • 1
codewario
  • 19,553
  • 20
  • 90
  • 159