65.9K
CodeProject is changing. Read more.
Home

How to get File Name from Full file Path

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.44/5 (15 votes)

Jul 3, 2010

CPOL
viewsIcon

30294

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:\