C# 访问父目录

C# 访问父目录,c#,asp.net,C#,Asp.net,如何获取以下目录的父目录 string rootFolder = System.Web.HttpContext.Current.Server.MapPath(APP_PATH); newdirectoryinfo(rootFolder).Parent.FullName或Directory.GetParent(rootFolder).FullNamenewdirectoryinfo(rootFolder).Parent.FullName或Directory.GetParent(rootFolde

如何获取以下目录的父目录

string rootFolder = System.Web.HttpContext.Current.Server.MapPath(APP_PATH);

newdirectoryinfo(rootFolder).Parent.FullName
Directory.GetParent(rootFolder).FullName

newdirectoryinfo(rootFolder).Parent.FullName
Directory.GetParent(rootFolder).FullName
使用。

使用。

你是指父物理文件夹?你是指父物理文件夹?出于某种原因,GetParent给了我完全相同的文件夹这就是我想要的文件夹:string str=Directory.GetParent(rootFolder).parent.FullName;在这种情况下,您可以使用
newdirectoryinfo(rootFolder).Parent.FullName
以提高可读性。出于某种原因,GetParent给了我完全相同的文件夹这就是我想要的文件夹:string str=Directory.GetParent(rootFolder).Parent.FullName;在这种情况下,您可以使用
newdirectoryinfo(rootFolder).Parent.FullName
以提高可读性。