Skip to content

Instantly share code, notes, and snippets.

@yuessir
Last active December 19, 2018 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuessir/5994dfdf47c48df6f4d2ee68bb829975 to your computer and use it in GitHub Desktop.
Save yuessir/5994dfdf47c48df6f4d2ee68bb829975 to your computer and use it in GitHub Desktop.
Dot Net Core Directory.GetParent Test
string suffixSlash = @"C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug\netcoreapp2.1\";
string suffixNoSlash = @"C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug\netcoreapp2.1";
string currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
string appContextBaseDirectory = AppContext.BaseDirectory;
string str1 = Directory.GetParent(suffixSlash).FullName;
string str2 = Directory.GetParent(suffixSlash).Parent.FullName;
string str3 = Directory.GetParent(str1).FullName;
string str4 = Directory.GetParent(suffixNoSlash).FullName;
string str5 = Directory.GetParent(suffixNoSlash).Parent.FullName;
string str6 = Directory.GetParent(str4).FullName;
//output
str1 :C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug\netcoreapp2.1
str2 :C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug
str3 :C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug
str4 :C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug
str5 :C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin
str6 :C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment