treeview - VB.NET 2008 Not recognizing Path.GetFileName Method -
i have read post nothing works. visual basic not recognizing path.getfilename method following page in trying filename in visual basic application can't compile microsoft official page
private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load size_mode_list.items.addrange([enum].getnames(gettype(pictureboxsizemode))) each drive driveinfo in driveinfo.getdrives dim node treenode = _ file_view_tree.nodes.add(drive.name) node.tag = itemtype.drive node.nodes.add("filler") next end sub private sub file_view_tree_beforeexpand(byval sender system.object, byval e system.windows.forms.treeviewcanceleventargs) handles file_view_tree.beforeexpand dim currentnode treenode = e.node currentnode.nodes.clear() try 'now go files , folders dim fullpathstring string = currentnode.fullpath 'handle each folder each dolderstring string in _ directory.getdirectories(fullpathstring) dim newnode treenode = _ currentnode.nodes.add(path.getfilename(folderstring)) dim x string = path.getfilename("") newnode.tag = itemtype.folder newnode.nodes.add("filler") next 'handle each file each filestring string in _ directory.getfiles(fullpathstring) 'get file name portion (without path) : dim newnode treenode = _ currentnode.nodes.add(path.getfilename(filestring)) newnode.tag = itemtype.file next catch ex exception end try end sub
'don't forget import imports system.io 'declare these private enum itemtype drive folder file end enum private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load each drive driveinfo in driveinfo.getdrives dim node treenode = _ file_view_tree.nodes.add(drive.name) node.tag = itemtype.drive node.nodes.add("filler") next end sub private sub file_view_tree_beforeexpand(byval sender system.object, byval e system.windows.forms.treeviewcanceleventargs) handles file_view_tree.beforeexpand dim currentnode treenode = e.node currentnode.nodes.clear() try 'now go files , folders dim fullpathstring string = currentnode.fullpath 'handle each folder each folderstring string in _ directory.getdirectories(fullpathstring) dim newnode treenode = _ currentnode.nodes.add(path.getfilename(folderstring)) dim x string = path.getfilename("") newnode.tag = itemtype.folder newnode.nodes.add("filler") next 'handle each file each filestring string in _ directory.getfiles(fullpathstring) 'get file name portion (without path) : dim newnode treenode = _ currentnode.nodes.add(path.getfilename(filestring)) newnode.tag = itemtype.file next catch ex exception end try end sub
Comments
Post a Comment