How to get File Name from Full file Path






3.44/5 (15 votes)
File Name from Path
The following tip will help you to dig out the following details from Full File Path:
1)
FileName
2) Extension
3) FileNameWithoutExtension
4) DirectoryName
5) PathRoot
Imports System.IO
Dim _FullPath As String = "C:\Users\Sony\Desktop\Readme.txt"
MsgBox(Path.GetFileName(_FullPath)) 'Returns >> Readme.txt
MsgBox(Path.GetExtension(_FullPath)) 'Returns >> .txt
MsgBox(Path.GetFileNameWithoutExtension(_FullPath)) 'Returns >> Readme
MsgBox(Path.GetDirectoryName(_FullPath)) 'Returns >> C:\Users\Sony\Desktop
MsgBox(Path.GetPathRoot(_FullPath)) 'Returns >> C:\