日期:2014-05-20  浏览次数:20905 次

如何做根状目录文件夹目录
FolderBrowserDialog   open   =   new   FolderBrowserDialog();

                        if   (open.ShowDialog()   ==   DialogResult.OK)
                        {
                                this.textBox_path.Text   =   open.SelectedPath.ToString();
                        }  

这个是浏览文件夹对话框
如何做一个类试功能但不是对话框而是窗体左边的一个功能
如图
http://61.153.32.58:8011/123.jpg

------解决方案--------------------
//下来看看,一个开源的
//我测试了效果很成

http://www.elavefenix.net/ficheros/My_Explorer_src.zip
------解决方案--------------------
//......
protected void PopulateDirectory(TreeNode nodeCurrent, TreeNodeCollection nodeCurrentCollection)
{
TreeNode nodeDir;
int imageIndex = 2; //unselected image index
int selectIndex = 3; //selected image index

if (nodeCurrent.SelectedImageIndex != 0)
{
//populate treeview with folders
try
{
//check path
if(Directory.Exists(getFullPath(nodeCurrent.FullPath)) == false)
{
MessageBox.Show( "Directory or path " + nodeCurrent.ToString() + " does not exist. ");
}
else
{
//populate files
PopulateFiles(nodeCurrent);

string[] stringDirectories = Directory.GetDirectories(getFullPath(nodeCurrent.FullPath));
string stringFullPath = " ";
string stringPathName = " ";

//loop throught all directories
foreach (string stringDir in stringDirectories)
{
stringFullPath = stringDir;
stringPathName = GetPathName(stringFullPath);

//create node for directories
nodeDir = new TreeNode(stringPathName.ToString(),imageIndex,selectIndex);
nodeCurrentCollection.Add(nodeDir);
}
}
}
catch (IOException e)
{
MessageBox.Show( "Error: Drive not ready or directory does not exist. ");
}
catch (UnauthorizedAccessException e)
{
MessageBox.Show( "Error: Drive or directory access denided. ");
}
catch (Exception e)
{
MessageBox.Show( "Error: " + e);
}
}
}