Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to get File Name from Full file Path

, 14 Jul 2010
Rate this:
Please Sign up or sign in to vote.
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:\</br>


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Koshy Panicker John
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

GeneralReason for my vote of 5 I must admit that i didn't knew it..... PinmemberGPUToaster18-Jul-10 6:56 
GeneralReason for my vote of 5 Path is one of the great overlooked ... PinmemberMartin Jarvis16-Jul-10 8:00 
GeneralReason for my vote of 5 Something so simple that has killed ... PinmemberAkash Badrinath15-Jul-10 22:46 
GeneralReason for my vote of 5 Why the low vote? It taught me somet... PinmemberAnt210014-Jul-10 6:37 
GeneralReason for my vote of 1 how come its a tip/tricks? PinmemberShahriar Iqbal Chowdhury3-Jul-10 5:24 
GeneralReason for my vote of 1 default functions PinmemberBugByter3-Jul-10 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 14 Jul 2010
Article Copyright 2010 by Koshy Panicker John
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid