logo  VB.Net - File Path
This Chapter
File Attributes
Binary File
Column Header
Copy Delete ...
CSV File
File Path
Text File
Chapters
Home Page
Colours, RGB
Computer Specifications
Dates&Times
Disk Drives
Files
Folders
GPS and OS Ref
VB.Net Forms
Image Files
If & Select
List/Array
Mathematics
NuGet
Sound
String Functions
Sun and Moon
User Controls
Validation
DigitalDan Sites
My Other Sites
Contact Site

Note
Some pages
may contain
inaccuracies
Hits=5
The IO.Path namespace accepts a string representing a full file name (e.g. "C:\digitaldan\image.jpg") and breaks it down into FolderName "c:\digtaldan" Filename "image.jpg" and extension ".jpg"
The functions split the filename supplied, regardless of whether a real file of that name exists.
 
Get Folder Name

   = IO.Path.GetDirectoryName(filename)
  
When file is in the root folder the final \ is included e.g. "C:\"
When file is in any sub-folder the final \ is missing e.g. "C:\digitaldan"
 
Get File Name Without the Extension

   = IO.Path.GetFileNameWithoutExtension(filename)
  
This returns just the file name, no path and no extension e.g. "image"
 
Get File Name Without the Extension

   = IO.Path.GetFileNameWithExtension(filename)
  
This returns just the file name and the extension e.g. "image.jpg"
When the extension is blank/not-present, this function removes the extension "."
 
Get File Name With Path and Extension

   = IO.Path.GetFullPath(filename)
  
This returns just the path (with final "\" file name and the extension e.g. "C:\digitaldan\image.jpg"
When the extension is blank/not-present, this function does not include the extension "."
 
Get Disk Drive from filename

   = IO.Path.GetPathRoot(filename)
  
This returns just the Disk Drive Name from the file name. It includes the final "\" e.g. "C:\"

DigitalDan.co.uk