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 enable you to manipulate pathnames. For example, you might want to extract the filename from a pathname. This is accomplished by 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 ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.