问题描述
Treeview添加本地文件目录的问题。。添加的时候,在第二级目录就连带上盘符了。。郁闷死。。求大虾帮忙看看代码有神马问题。。[img=http://my.csdn.net/my/album/detail/1096621#][/img]PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickDimDriveCountAsInteger=IO.DriveInfo.GetDrives.LengthDimdrivesNameAsString()=Environment.GetLogicalDrives()DimiDirAsIO.DirectoryDimiAsIntegerTreeView1.Nodes.Clear()Fors=0ToDriveCount-1DimnodeAsNewTreeNodenode.ImageIndex=0TreeView1.Nodes.Add(node)node.Text=drivesName(s)IfDriveInfo.GetDrives(s).IsReadyThenDimDriverstr()AsString=Directory.GetDirectories(drivesName(s))Fori=0ToDriverstr.GetUpperBound(0)MsgBox(Driverstr(i))AddDirectory(drivesName(s),Driverstr(i),node)Nextnode=NothingiDir=NothingEndIfNextEndSubPublicSubAddDirectory(ByValstrFatherPathAsString,ByValstrPathAsString,ByValnodeFatherAsTreeNode)DimiDirAsIO.Directory'DimiDirInfoAsIO.DirectoryInfoDimiAsIntegerDimnodeAsNewTreeNodenode.Text=Strings.Replace(strPath,strFatherPath&"","",,1)node.ImageIndex=1node.SelectedImageIndex=2nodeFather.Nodes.Add(node)Application.DoEvents()TryDimstr()AsString=Directory.GetDirectories(strPath)Fori=0Tostr.GetUpperBound(0)AddDirectory(strPath,str(i),node)NextCatchexAsExceptionDebug.WriteLine(ex.Message)EndTrynode=NothingiDir=NothingEndSub
解决方案
解决方案二:
参考:http://topic.csdn.net/u/20120324/21/c2784a5b-c359-40f1-a250-ab96be1bb71f.html
解决方案三:
本人表示完全不懂C#。。求助。。
解决方案四:
在第二级目录就连带上盘符了。-----------????
解决方案五:
二级目录有盘符,就要进行字符操作,取所需要的字符串。