The System.IO.Path Class
Often you need to work with pathnames, directory names, and filenames. The .NET Framework provides the System.IO.Path class, offering shared members that allow manipulating pathnames. For example, you might want to extract the filename from a pathname. This is accomplished invoking the GetFileName method as follows:
'Returns "TextFile.txt" Dim fileName As String = Path.GetFileName("C:\TextFile.txt")
The GetExtension method returns instead only the file extension and is used as follows:
'Returns ".txt" Dim extension As String = Path.GetExtension("C:\TextFile.txt")
To ensure that a filename has an extension, you can also invoke the HasExtension method that returns True if the filename has one. There are situations in which ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access