C# 获取当前路径的上一级(父级目录)

string path = "D:\\test\\test1\\demo";
Directory.SetCurrentDirectory(Directory.GetParent(path).FullName);
string parentPath = Directory.GetCurrentDirectory();//parentPath = D:\\test\\test1

 

你可能感兴趣的:(C#)