DirectoryInfo GetPrant(DirectoryInfo path, int level)
{
DirectoryInfo temp = null;
if (level > 1)
{
level--;
temp = GetPrant(path.Parent, level);
}
else
temp = path;
return (temp);
}
调用
int LEVEL = 10;
string NAME = GetPrant(Directory.GetParent(FullPath), LEVEL ).Name;
LEVEL 为父目录级别,1为本身;FullPath为全路径,通过路径过去对应目录