DirectoryInfo dir = new DirectoryInfo(e.Node.FullPath);
DirectoryInfo[] folds = dir.GetDirectories();
foreach(DirectoryInfo f in folds)
{
TreeNode subnode = new TreeNode();
subnode.Text = f.Name;
e.Node.Nodes.Add(subnode); }
未处理的“System.NotSupportedException”类型的异常出现在 mscorlib.dll 中。其他信息: 不支持给定路径的格式。       我一点驱动器就出这样的错,我拿同样的代码在别人的机器上用就是好的,怎么回事啊,高手们指点啊

解决方案 »

  1.   

    1.看是不是你的磁盘的FAT表有问题,建议用Norton的Norton Disk Doctor将你的磁盘先检查一遍。2.请指明,这个异常是从哪一行抛出的?
      

  2.   

    异常是从
      DirectoryInfo dir = new DirectoryInfo(e.Node.FullPath);
        这一行抛出的,说的就是  DirectoryInfo的参数不对
             不光是a盘,我点哪个驱动器 都是同样的问题,完全的代码如下:
       private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e){ e.Node.Nodes.Clear();
    DirectoryInfo dir = new DirectoryInfo(e.Node.FullPath);→抛出异常的行
    DirectoryInfo[] folds = dir.GetDirectories();
    foreach(DirectoryInfo f in folds)
    {
    TreeNode subnode = new TreeNode();
    subnode.Text = f.Name;
    e.Node.Nodes.Add(subnode); }



    }

                   
    }
      

  3.   

    DirectoryInfo dir = new DirectoryInfo(e.Node.FullPath);
    debug 一下,看看传入的e.Node.FullPath是否为合法的值
      

  4.   

    我检查过了
          路径没问题的,我的treeview的根节点是 "外部管理目录"
           上叙代码是属于 子节点,我messagebox.show出来的值是 "外部管理目录/d:/" 没错啊...
      

  5.   

    "外部管理目录/d:/"这样还没有错?管理目录后,还可以这样接d:\?我感觉这不是个合理的Pathtry{
    DirectoryInfo dir = new DirectoryInfo(e.Node.FullPath);→抛出异常的行
    }
    catch(Exception e)
    {
      if(e is System.NotSupportedException)//用来确定,这个System.NotSupportedException就是它直接抛出的
        MessageBox.Show("NotSupportedException");
      else
        MessageBox.Show(e.Message.ToString);
    //在MSDN里,这个new DirectoryInfo(e.Node.FullPath);可能抛出的异常是四种,没有你说的这个System.NotSupportedException异常啊,晕晕地
    }