Get Parent Folder in C#
How to get parent folder of a folder with C# and .NET.
You must import the System.IO before you can use this class.
The Parent property of DirectoryInfo returns the parent directory as a DirectoryInfo. We can use the FullName property to get the full name of the directory.
The following code snippet does the same.
string root = @"C:\Temp\Mahesh";
DirectoryInfo di = new DirectoryInfo(root);