DirectoryInfo.Parent Property gets the parent directory of a specified subdirectory.
Imports System
Imports System.IO
Public Class MoveToTest
Public Shared Sub Main()
Dim di As New DirectoryInfo("TempDir")
If di.Exists = False Then
di.Create()
End If
Dim dis As DirectoryInfo = di.CreateSubdirectory("SubDir")
Dim parentDir As DirectoryInfo = dis.Parent
Console.WriteLine("The parent directory of '{0}' is '{1}'", dis.Name, parentDir.Name)
di.Delete(True)
End Sub
End Class
Related examples in the same category