VB.Net - Path Object

Micrsoft recommends you use the Path class, when you are playing with directories. The path class has a number of functions, here is a survey of a few:

1
2
3
Dim theFile As String = "C:\test\test.doc"
Dim thepath As String = Path.GetDirectoryName(theFile)
Dim filename As String = Path.GetFileName(theFile)

The first statement simply initializes a variable named ‘theFile’

Path.GetDirectoryName - is a method that pulls the path out of a variable. In this case the output would be “c:\test”.

Path.GetFileName - is a method that pulls the filename out of a variable. In this case the output would be “test.doc”