I need a BrowseForFolder in C#!

G

Guest

I'm attempting to find the class that I can use to get a "Browse For Folder" dialog similar to SHBrowseForFolder, in C#. I can't seem to find anything that comes close.

I'm developing a small, small application to create M3U Playlists from my hierarchical organization of digital audio. I have the application working but I want to give myself the ability to easily select both the starting folder (on my file server), and the output folder (a local folder on my various PCs and laptops around the house). An OpenFileDialog just won't do the trick. I need that BrowseForFolder dialog. . . . but haven't found it in the Framework

I know I could create a dialog with a TreeView and buttons that would approximate my needs, but why should I add an entire logical tree-and-node structure to a program that's got less than 300 lines of code? As everyone is saying these days, "why reinvent the wheel"

Thanks for any help you can give

Ryan T
 
B

Bill Styles

Ryan Trevisol said:
I'm attempting to find the class that I can use to get a "Browse For
Folder" dialog similar to SHBrowseForFolder, in C#. I can't seem to
find anything that comes close.

System.Windows.Forms.FolderBrowserDialog browse =
new System.Windows.Forms.FolderBrowserDialog();
browse.ShowNewFolderButton = false;
browse.Description="Please select a folder";
browse.RootFolder=System.Environment.SpecialFolder.DesktopDirectory;
browse.SelectedPath = "apps";
if (browse.ShowDialog()==System.Windows.Forms.DialogResult.OK)
MessageBox.Show(browse.SelectedPath);
else
MessageBox.Show("Cancelled");
 
B

Bram

Hi,

One remark here,
this class is only available in version 1.1 of the framework.

Greetings,

Bram
 
G

Guest

That makes sense. I may be working under 1.0 . . . My copy of .NET was provided by my school (fau). I'll have to check. But since that didn't show up under the Forms namespace (I read each entry), I can assume I have the old version.

If I have that version of .NET Professional (1.0), which is under license from my school, can I upgrade it? (read: free?)

Thanks for that help.
 
G

Guest

Sorry for being such a newbie . . .

I think if I just understood the .NET website correctly, that I only need to install the 1.1 SDK in order to have access to the new classes in Visual Studio? Is that the case?

Sorry for being such a pest. I've been programming in .NET for all of 2 weeks.
 
P

Patrick Steele [MVP]

I think if I just understood the .NET website correctly, that I only need to install the 1.1 SDK in order to have access to the new classes in Visual Studio? Is that the case?

Installing the 1.1 SDK will only give you the compilers. VS.NET 2002
only works with the 1.0 framework, so you'd have to stop using VS.NET
(or go to VS.NET 2003 and you can then target both 1.0 and 1.1).

If you need to interop with the SHBrowseForFolder in 1.0 see:

http://weblogs.asp.net/psteele/articles/7536.aspx

It's VB.NET, but could easily by ported to C# (or compiled in VB.NET as
a DLL).
 
G

Guest

Well if that's the case I can't move up to 2003 because I can't afford it, but I can use the handy-dandy, 1.1-Compatible SharpDevelop (www.icsharpcode.net) to compile it (I just tried on my laptop, which is too slow for VS.NET but runs SharpDevelop). I haven't run into any other limitations so far so I'll keep plugging along with VS.NET2002. . .

Thanks for the help.
 
T

Tom Shelton

Well if that's the case I can't move up to 2003 because I can't afford it, but I can use the handy-dandy, 1.1-Compatible SharpDevelop (www.icsharpcode.net) to compile it (I just tried on my laptop, which is too slow for VS.NET but runs SharpDevelop). I haven't run into any other limitations so far so I'll keep plugging along with VS.NET2002. . . .

Thanks for the help.

Didn't the uprgrade to 2003 cost $29? Not sure if that applies any
more.
 
C

Chuck Conlow

I've seen this 'set-up' mentioned before, but does anyone have the steps
necessary to get VS 2002 to use (IDE and compile) against the 1.1 Framework?
I thought I saw mention of 'inconsistencies' and 'undependable' operation.

Chuck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top