I have read this post but nothing works.
Visual Basic not recognizing Path.GetFileName Method
I am following this page in trying to get the filename in my Visual Basic application but i can't compile it Microsoft Official Page
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
size_mode_list.Items.AddRange([Enum].GetNames(GetType(PictureBoxSizeMode)))
For Each drive As DriveInfo In DriveInfo.GetDrives
Dim node As 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 As System.Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles file_view_tree.BeforeExpand
Dim currentNode As TreeNode = e.Node
currentNode.Nodes.Clear()
Try
'Now go get all the files and folders
Dim fullPathString As String = currentNode.FullPath
'Handle each folder
For Each dolderString As String In _
Directory.GetDirectories(fullPathString)
Dim newNode As TreeNode = _
currentNode.Nodes.Add(path.getFileName(folderString))
Dim x As String = path.GetFileName("")
newNode.Tag = ItemType.Folder
newNode.Nodes.Add("FILLER")
Next
'Handle each file
For Each fileString As String In _
Directory.GetFiles(fullPathString)
'Get just the file name portion (without the path) :
Dim newNode As TreeNode = _
currentNode.Nodes.Add(path.getFileName(fileString))
newNode.Tag = ItemType.File
Next
Catch ex As Exception
End Try
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…