开发者

How to Browse a particular folder

I have a folderBrowserDialog control and i have a button named click i did like this way

 private void click_Click(object sender, EventArgs e)
    {
        folderBrowserDialog1.ShowDia开发者_开发百科log();
    }


If what you wish to accomplish is to automatically display a folder of your choice whenever the FolderBrowserDialog is shown, then you can use the following code:

private void click_Click(object sender, EventArgs e)
{
    FolderBrowserDialog f = new FolderBrowserDialog();

    f.Description = "Please browse to, and select a folder";
    f.RootFolder = @"C:\Name Of Folder You Want Displayed\";

    using(f)
    {
        if(f.ShowDialog() == DialogResult.OK)
        {
            // Do something when the user clicks OK or Open.
        }
    }
}

Or, you could simply add a FolderBrowserDialog to your Form from the Visual Studio ToolBox and click on the Properties tab, and then click the down arrow to the right-hand side of the 'Root Folder' option and select one of the listed folders from the drop-down menu.

Hope this helps.


You can use a custom build Folder Browser Dialog/Control for this. Try this: http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜