Reputation: 3589
How do I get a parent of a directory, for example:
string upDir = GetOneLvlUp(@"C:\AAA\BBB\CCC\DDD\");
Output: C:\AAA\BBB\CCC\
Upvotes: 24
Views: 40945
Reputation: 61
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string parentDir = Directory.GetParent(path).FullName;
Upvotes: 6
Reputation: 26917
Everything you want is in the Directory class:
http://msdn.microsoft.com/en-us/library/system.io.directory.aspx
In particular, GetParent:
http://msdn.microsoft.com/en-us/library/system.io.directory.getparent.aspx
Upvotes: 7