How to get only directory name from full file path c#

Question:

How to get only directory name from full file path c#

Answer:

var targetPath = new DirectoryInfo(txtFolderPath.Text);
var folderPath = targetPath.Parent.FullName;
Scroll to Top