Home All Groups Group Topic Archive Search About

Create a Folder Browser in C#

Author
16 May 2006 11:37 AM
fir5tsight
Hi,

How can I create a *folder* browser (not file browser)? This means if
the user selects a folder and then selects "OK", the dialog closes and
returns the folder name.

Now I have the code in C# that allows the user to select a file name.
However, I'll only need to select a folder. What changes do I have to
make?

private void Browse_Click(object sender,
System.EventArgs e)
{
    axCommonDialog.FileName = txtInput.Text;
    axCommonDialog.ShowOpen();
    txtInput.Text = axCommonDialog.FileName;

}

The definition of axCommonDialog is
private AxMSComDlg.AxCommonDialog axCommonDialog;

Many thanks!

Author
16 May 2006 3:16 PM
Norman Yuan
You are not still using .NET 1.0, are you? Since .NET 1.1, there is
FolderBrowser control available in Windows.Forms namespace.

<fir5tsi***@yahoo.com> wrote in message
Show quote
news:1147779435.639910.240940@i40g2000cwc.googlegroups.com...
> Hi,
>
> How can I create a *folder* browser (not file browser)? This means if
> the user selects a folder and then selects "OK", the dialog closes and
> returns the folder name.
>
> Now I have the code in C# that allows the user to select a file name.
> However, I'll only need to select a folder. What changes do I have to
> make?
>
> private void Browse_Click(object sender,
> System.EventArgs e)
> {
> axCommonDialog.FileName = txtInput.Text;
> axCommonDialog.ShowOpen();
> txtInput.Text = axCommonDialog.FileName;
>
> }
>
> The definition of axCommonDialog is
> private AxMSComDlg.AxCommonDialog axCommonDialog;
>
> Many thanks!
>

AddThis Social Bookmark Button