|
-
May 6th, 2003, 06:17 PM
#1
Thread Starter
Junior Member
Browse for Folder **RESOLVED**
Ok, i know this must've been posted a million times in VB but I'm a new C# programmer and frankly I have no clue as how to do this in C#, so please help me out 
Code:
private void button3_Click(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.ShowDialog();
textBox1.Text = openFileDialog1.FileName;
}
How do I turn this into a Folder browsing dialog? This only selects existing files. I've seen the VB code involved for this and it's, for a lack of a better word, ridiculously complex! Isn't there a built-in method or class for this in C#? Thanks in advance!
Last edited by eanatum; May 7th, 2003 at 01:06 PM.
-
May 6th, 2003, 09:41 PM
#2
Frenzied Member
There is a folder browser dialog in VS.NET 2003. There is none in VS.NET 2002, so you will have to use API calls are you can use a custom control from this website http://www.sellsbrothers.com
-
May 7th, 2003, 09:57 AM
#3
yay gay
that aint truth, you can use the System.Design.FolderNameEditor if i am not mistaken
\m/  \m/
-
May 7th, 2003, 10:34 AM
#4
-
May 7th, 2003, 11:29 AM
#5
Frenzied Member
Originally posted by PT Exorcist
that aint truth, you can use the System.Design.FolderNameEditor if i am not mistaken
He may be able to use that, but I dont think thats what he is looking for.
-
May 7th, 2003, 01:03 PM
#6
Thread Starter
Junior Member
Actually, I think it is! The link provided by Cander had exactly what I needed. This is what I ended up with:
Code:
using System.Windows.Forms.Design; // Necessary for BrowseForFolder
public class BrowseForFolder : FolderNameEditor
{
FolderNameEditor.FolderBrowser fBrowser;
public BrowseForFolder()
{
fBrowser = new System.Windows.Forms.Design.FolderNameEditor.FolderBrowser();
}
public string ShowIt(string textDescription)
{
fBrowser.Description = textDescription;
fBrowser.ShowDialog();
return fBrowser.DirectoryPath;
}
~BrowseForFolder()
{
fBrowser.Dispose();
}
}
private void button3_Click(object sender, System.EventArgs e)
{
BrowseForFolder folderDialog = new BrowseForFolder();
textBox1.Text = folderDialog.ShowIt("Please select a folder:");
}
IMPORTANT: You must also add a reference to 'System.Design.dll' in the Solution Explorer for this to work.
I got this working perfectly. Hope this code helps others. Thanks a million, guys!
-
May 7th, 2003, 01:26 PM
#7
IMPORTANT: You must also add a reference to 'System.Design.dll' in the Solution Explorer for this to work.
I keep forgetting to tell people that!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|