Below is a technique that uses FolderNameEditor and FolderBrowser classes to implement a solution. You can also use iterop to get a solution.
Both the FolderNameEditor and FolderBrowser classes used in this solution are described in the Docs as "This type supports the .NET Framework infrastructure and is not intended to be used directly from your code."
// add a reference to System.Design.DLL
using System.Windows.Forms.Design;
public class DirectoryBrowser : FolderNameEditor
{
private string description = "Choose Directory";
private string returnPath = string.Empty;
FolderBrowser browser = new FolderBrowser();
public string Description
{
get { return description; }
set { description = value; }
}
public string ReturnPath
{ get { return returnPath; } }
public DialogResult ShowDialog()
{
browser.Description = description;
browser.StartLocation = FolderBrowserFolder.MyComputer;
DialogResult result = browser.ShowDialog();
returnPath = ( result == DialogResult.OK )
? browser.DirectoryPath
: string.Empty;
return result;
}
}
Ryan Farley